Script Attributes: Curve

I’m trying to incorporate a curve script attribute into one of my scripts.
I’ve been trying to find documentation about how to set default values for a curve, but I can’t seem to find any info or figure it out…

MyScript.attributes.add('somecurve', { type: 'curve', curves: ["TheCurve"], title: "The Curve" });

how can I add a default value of -5 at time stamp 0 and 5 at time stamp 1?

In this situation, I offer you to create curve in Editor, run your project and find values from console.

So, in my case in was like:

You can inspect properties and methods of this object to find a way to add points.

Spoiler"ps1").particlesystem.localVelocityGraph.curves[0].add(time, value)

So you have to create curve, add points and then set it to your field.

1 Like

Hi, thanks I know how to use the console.
I also know the values I want to set and I also read the documentation, so I’ve seen the function “add”.
This is not my question, my question is how to set keys as default values when declaring a curve script attribute.

For example:
If you declare a number attribute:

MyScript.attributes.add("myNumber",{type:'number',title:'A Number', default: 3});

default: 3 will make the default value of your number attribute 3

I’m looking for the equivalent for a curve attribute to set two keys as the default

Hi @Dinkelborg_At_C4Real, I’m afraid you can’t set default values on a curve set attribute at this time although it is something that is on our list todo. Sorry :frowning:

1 Like

Hi, @steven
Is it an issue that when I create curve attribute with custom curvers’ names?

Script.attributes.add("curve", {
    type: "curve",
    name: "testCurve",
    curves: ['a', 'b', 'c'],

I still have x, y, z

I’m not sure about this point, because names have no sence in this case.

It seems to work for me. It looks like there is a little bug where if you have the Entity selected and you change the names of the curves in your script and reparse the script, the names in the UI don’t change until you re-select the Entity. Is that what happens for you? (reminder that you need to reparse the script if you make changes to its attributes).

1 Like

Yes, you’re right.
When I reselect entity, problem goes away.

Hey guys, is there a way to set a default type for curve?

SomeScript.attributes.add('someCurve', { 
    type: 'curve', 
    default: {
        type: pc.CURVE_SMOOTHSTEP,   <<< how to set default type?
        keys: [ 0, 0, 0.5, 0, 0.7, 1, 1, 1 ]

1 Like