Rigidbody2D not detecting gravity

I created a Character (by creating an Empty Game Object) and added the following Components to it:

  • Transform(already attached)
  • Rigidbody2D
  • Sprite Renderer
  • Polygon Collider 2D
  • Animator (after creating Animations)

When I run the game I expect the Character to ‘fall’ because of gravity and the Rigidbody2D that is attached, but nothing happens.
Only the Default Animation runs through its frames.

After doing a bunch of testing (i.e. adding other Game Objects to the game that do ‘fall’) I realize the lack of gravity and Rigidbody2D reaction must have something to do with the Animations that I’ve added to my Character. I’ve even tried adding a script that ‘AddsForce’ to the Rigidbody2D but it does not move at all.

When I created the animations, on the default animation I added a ‘Curve’ that Transforms the Position slightly and I figure this must have something to do with overriding the Rigidbody2D but I cannot for the life of me figure out why or fix it.

Please help

Adding a Rigidbody2D obviously puts it in control of the Transform position. By setting the Transform position directly, you’re undermining that because when you set the Transform directly, it’ll set the Rigidbody2D position, stomping on anything that the physics system does to move the Rigidbody2D.

In other words, you’re asking it to do two conflicting things.

I understand that but I’m not using any sort of script to change the Transform position at all.

My understanding is that if you apply a ‘Curve’ to the Animation it is relative to where the sprite is located… not a global adjustment to the Transform’s position. Am I thinking about this incorrectly?

Agreed, it’s not a script, it’s the Animation component as you’ve already said that is changing the Transform. Whether the change is relative or not still doesn’t alter the fact that you’re updating the Transform position and likewise, this causes the Rigidbody2D to sync with it i.e. you’re controlling the position of the Rigidbody2D via the Transform.

When animating in such a scenario, the Rigidbody2D should really be set to kinematic as you’re controlling it directly. Kinematic bodies are also not affected by gravity.

Gotcha… thank you very much!