- Home /
Tranform Animation Curve ruins Gravity
Hey guys,
I'm very new to Unity. Been doing it about two days now.
I'm about done making a Flappy Bird clone. The only thing left for me to do was the intro portion where the bird oscillates up and down. So I made an Animation for it and added a curve for Transform->Position. I succeeded in making the bird oscillate up and down.
But then afterward the Gravity on the Bird wouldn't work any more! The Bird has a Rigidbody 2D on it. I set the GravityScale before the animation to 0 and then afterward to 1. Even omitting the GravityScale being set to 0, still no Gravity. I then made it so the Animation with the transform curve never played, STILL no Gravity. I checked and unchecked "Apply Root Motion" to no success. Only after I either remove the animation or remove the position curve entirely does Gravity start to work again. Why would this be? ESPECIALLY when the animation doesn't even play?
Interestingly, while the Gravity was failing, the Bird would still rotate back and forth from flaps and its downward velocity (from a Lerp), meaning it was receiving "velocity" changes despite not moving.
And then, when I tried to change the Curve instead to a rotation curve, it would rotate in the animation, gravity would work, but then I couldn't set the rotation after the animation finished from code! It always stayed at 0.
Why did my gravity fail to work?
What is the best practice to handle animations on objects with rigidbodies?
What's the easiest way to make my oscillation animation without affecting the physics?
Thanks!
Answer by jouyang3 · Sep 19, 2014 at 01:00 AM
I have encountered the same issue. I have read this article and applied its fixes but it doesn't really work out at the end. Apparently, it states that there's an issue between animation update rate and physics update rate.
Regardless, here's the URL, I hope you might find it useful:
http://grovecodeblog.wordpress.com/2013/10/30/combining-physics-and-animation-in-unity/
Your answer
Follow this Question
Related Questions
Create a linear animation curve with javascript 1 Answer
My Mecanim-Generic is screwing with the gravity 2 Answers
Animation Events and Mecanim 2 Answers
Evaluating Animation Curves in Full 0 Answers
Gravity does not work with animation. 2 Answers