- Home /
Rigidbody gets stuck on wall?
I have a mecanim-controlled character with a rigidbody attached. The character moves using Root Motion from the Animator. When the character jumps and hits a wall, he gets stuck. I've heard this problem has happened before with RigidbodyWalker scripts but I haven't been able to find a solution.
Is there a way to ensure the player doesn't get stuck floating in a wall after jumping?
In a similar question, the issue was that the rigidbody went to sleep. This is unlikely to be your issue, but it is easy to check. Put a Debug.Log(rigidbody.isSleeping) in the code and duplicate the wall sticking behavior.
No... could it be due to the fact that the root animation is moving him forward?
Do you have the box checked in the inspector "Animate Physics"?
Yes I do. Seems to be he's partially embedded in the wall, which means the root animation probably shoved him a little too far... Is there a way to stop that from happening? Also it only happens when the player is in the air...
Try placing a new, bigger collider around your character, make that collider a trigger. Use something like OnTriggerEnter reacting to the tag "Wall", or whatever he will be colliding with. Not sure if this will help because I'm not too experienced w/ animation. But I would try this, and set the trigger script to either push your character back out of the wall, or slow his velocity, or increase the rigidbody drag while moving in air toward the wall...
That seems kind of tedious because it's supposed to be an automated system... I tried using OnCollisionEnter and OnCollisionStay with AddForce to use force to push the character out of the wall but that doesn't work either... There has to be some kind of option that stops root animations from going through colliders...
Answer by SomeGuy22 · May 28, 2013 at 12:16 AM
"Alright so apparently changing the mass of the rigidbody to 1 fixes this and causes him to collide properly. I have no idea why this solved it and I would like to set the mass back to a more realistic value but if anyone has any idea on why changing the mass fixes this I'd be glad to hear it :P"