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.

  1. Why did my gravity fail to work?
  2. What is the best practice to handle animations on objects with rigidbodies?
  3. What’s the easiest way to make my oscillation animation without affecting the physics?

Thanks!

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: