- Home /
Animator and Rigidbody2D Conflicting. Help~
Hi guys and ladies,
So i've got a character set up using a hierarchy of sprites and a simple IK script attached to it. at the top of the hierarchy, i've got an empty gameobject which i've added animation controls and rigidbody2D to it.
The issue i'm facing is that it seems the animator is conflicting with the physics. On the animator, i've unchecked "apply root motion", changed update mode to "animate physics", but despite doing this, AddForce is giving me weird results.
Eg.
1) AddForce(new Vector2D(500, 0)) does not move the character horizontally.
2) AddForce(new Vector2D(0, 500)) "teleports" the character UP instead of pushing it gradually up.
3) the mass and gravity seems haywire too. the character is "super heavy", but drops super slow.
4) if i set the character to start from a drop, when it collide with something, it resets back to the start (drop) position.
Anyone know what i'm doing wrong? Any help would be appreciated. Thanks!!! :)
Answer by Spidlee · Sep 09, 2014 at 05:52 AM
Ok for anybody else who has this issue (and i've seen alot of people with this issue), I managed to resolve my issue with rigidbody2D & animator conflict with the below "hack".
So the way i did my animations was via the head of the hierarchy. This allowed me to manipulate all the children under one controller. Because of that, I also added the rigidbody2D and boxcollider2D onto this head. That's where the conflict happens. So to solve this, I added the whole hierarchy under another empty game object, which gives it a new head that has no animator. Add the rigidbody2D and whatever else, boxcollider2D, playercontroller script, etc to this new head. And SOLVED :)
Below is the visual solution, hope this helps someone else :D
Old Hierarchy: Player (head of char, of which animations are done via, animator is attached here. DO NOT PUT THE RIGIDBODY2D here.) -> Sprite parts (has its own hierarchy again) -> etc
New Hierarchy: PlayerController (NO ANIMATOR, attach rigidbody2D here) -> Player (Animator here) --> Sprite parts --> etc
Ths worked for me. Thank you so much for sharing this.
Your answer
![](https://koobas.hobune.stream/wayback/20220613162545im_/https://answers.unity.com/themes/thub/images/avi.jpg)