Editing animation curves in a script
Hey there!
I've been trying to set the keyframes of an animation curve in script, but for some reason it isn't using the values I assign to it. See the below picture.
As you can see in the code, the value of the last key should be 0.5, and the value of the fourth should be 1. But those two are inverted. Anyone know how I can fix this?
Answer by tanoshimi · Apr 16, 2016 at 07:24 AM
That curve looks correct to me, assuming spline.SplineLength has a value of about 21?
....
keyFrames[3].time = 1.5 * spline.SplineLength;
keyFrames[4].time = spline.SplineLength;
....
So the value on the right hand end of the curve is keyFrames[3], not keyFrames[4]...
Answer by Varaughe · Dec 16, 2019 at 05:20 PM
If for some you wanna edit the curves visually, not in script, check out Runtime Curve Editor: https://assetstore.unity.com/packages/tools/gui/runtime-curve-editor-11835