Collisions Detection Functions Not Called, Walking Through Walls

Sorry for asking such a common question, but I’ve gone through so many answers / tutorials, but they all seem slightly different or I’m not understanding how apply those solutions to my problem.

The GameObjects:

  1. A wall with box collider that is enabled and is not a trigger. The wall has no rigidbody.

  2. An animated character with many rigidbody and collider components so that animation can be turned off and he can ragdoll.

What works:

The animations look great, the conversion to ragdoll looks great, the character’s feet stay solid on the floor. Many hours of experimenting and reading to figure all that out.

What doesn’t work:

Collisions are not detected with the wall (or other characters). The character walks right through and the character’s functions for OnCollisionEnter (or OnTriggerEnter) do not get called.

What I’ve tried:

I’ve tried setting the 4 variables below in different combinations it to get collisions working. None seem to help.

What am I not understanding?

protected void EnableCollisionDetection()
    foreach (Rigidbody rb in gameObject.GetComponentsInChildren<Rigidbody>())
        rb.isKinematic = false;
        rb.detectCollisions = true;
    foreach (Collider c in gameObject.GetComponentsInChildren<Collider>())
        c.enabled = true;
        c.isTrigger = true;

IsKinematic should be false unless you check for collisions using a raycast by hand.

IsTrigger should definitely be false if you want to interact with the world.

If you use a dynamic rigidbody, you should use AddForce or .velocity, not MovePosition nor .position.

Also check

  1. Layers
  2. IgnoreCollision calls
  3. MeshColliders with rigidbodies

Thanks for the response.

  • I have tried isKinematic false along with isTrigger false.

  • I have only the default layer

  • I have no mesh colliders, only simple ones

  • I don’t have any code to IgnoreCollisions, and I double checked the Project Settings to make sure all collision detection types are on.

  • The character is moved by the animation, no force or scripted movement involved.

  • What’s a dynamic rigidbody? Do you mean Collision Detection on the Rigidbody set to Continuous Dynamic? If that is the case, no, I have it set to discrete since I don’t have any fast moving objects or needs for precision collision detection.

Any other ideas? Keep em coming! Much Obliged!

In my case, I add a character controller on the animated object. I have this zombie character that has animation when get hit. When this zombie dies, I disable the character controller, animator, and iskinematic. When the zombie is still alive the collisions work well because of the character controller. But when it dies, the ragdoll also works well because the character controller, animator and iskinematic is set to disable