Hello, the commUnity!
Currently I’m working on a character controller system, based on using Mecanim (animations move the character). So I’ve watched this tutorial and made practically the same. In particular, I’ve added a rigidbody component and a capsule collider to the character. Everything worked fine, until I’ve decided to use a ragdoll instead of a death animation: the character now slides slightly in the forward direction. In fact, it is standing on the horizontal plane, so the gravity force doesn’t seem to be able to move the character.
I wanted to reply to this older post because it was the only post that seemed relevant to an issue I had been looking for an answer to. I hope this will help others trying to fix the issue.
In my instance of this problem, the ragdoll was colliding with the character controller Capsule Collider.
In the picture attached you can see the larger character controller capsule sphere and then the ragdoll capsules and boxes around each limb of the character. What was happening in my scene was the physics engine was battling the capsule collider causing many collisions. This resulted in my character moving in a direction and in my case many directions pretty quickly so I was basically flying around the map… It was very confusing. So I then tried to remove the animator and found that my character was no longer flying because he would just ragdoll without any animations playing. But i noticed that when I hit ‘play’ the character ragdoll would launch away from the larger capsule collider to get out of it. I then realized that you must use the edit>project settings>physics tap to set the layers so that they ignore collisions on each other. In my case i set the hips of the character (which contains all of the characters limbs) to the ‘ragdoll’ layer and then unchecked the ‘player’ layer which was where my sphere collider resides. Then bam no more flying or weird ragdoll getting launched away from my capsule collider.
Three steps to solve this problem:
set your character to “player” layer, only the top object, do not include children. (you should create this layer yourself)
set the character’s hips to “Ragdoll” layer. Also, create the layer by yourself. This time include all chidren of hips.
add this line to your script:
(assume layers created above are layer8 and layer9)
Physics.IgnoreLayerCollision (9, 8, true);
It works perfectly! Thanks!!!