- Home /
How can I set my Animation Curve's Tangents to Flat in script?
I have an animation that I've generated through script with three keyframes. The first is just the resting position, the second moves it down along the y-axis some ways, then the third frame moves it back to the resting position.
In my code, when I create the middle keyframe I am using AnimationCurve.AddKey() which by default will smooth the animation tangents for you. This makes the tangents look like so.
The problem with this is that the animation of my y-axis curves underneath my destination which doesn't seem like a lot here but when the animation changes in scale it can dip well underneath half my requested position. What I would like for the tangents to look like is this.
I know I can just go into the Animation Window and right click the key frame and sort this all out, but that isn't the question here so pretty please don't recommend that! Thanks for taking the time to read this and I hope you can help me!
Edit : Here is an image where this is REALLY getting out of hand and Unity just takes the flag and runs with it lol.