|
I want to set both tangents of a Keyframe in an AnimationCurve through scripting, just like it is possible to do in the Animation view in Unity. How can I do it in code?
(comments are locked)
|
|
If you have an AnimationCurve called myAnimationCurve, you can get a Keyframe from this curve and set the tangents of that Keyframe like this:
You can also smooth out the tangents of a Keyframe by using SmoothTangents on the AnimationCurve:
The second parameter, weight, controls the contribution of the two tangents in the smoothed result. -1 makes the smooth result equal to what the inTangent was before; 1 makes it equal to what the outTangent was, and 0 produces an average. can i use myAnimationCurve.keys[3].inTangent = 1 directly?? and can you plz explain the SmoothTangents i just cant get it does it take only 0,-1,1??? thxxx
Sep 02 '10 at 04:36 AM
vyruz
No you can't set myAnimationCurve.keys[3].inTangent directly since it would just modify a struct which is never assigned back into the curve. SmoothTangents takes a float that can be anything in between -1 and 1.
Sep 02 '10 at 01:03 PM
runevision ♦♦
(comments are locked)
|
