Kinematic Rigidbody Through Static Collision

So, frankly I’m not sure what the best approach to this is. Any insight or tips would be much appreciated.

I have a character walking through an environment. I don’t want him walking through walls or other static collision. The ground is flat, I expect many of these characters…so I don’t want or need a character controller. They need to be able to become airborne as well.

The thing is, I have a bunch of rigidbodies (non-kinematic) that I don’t want to actually affect my characters’ movement. I DO need them to collide, but I DO NOT want the character to actually move, so that leads me to assume the characters need to be kinematic. From what I’ve seen, it looks like a kinematic rigidbody can move wherever it wants (aka through even static geometry). Character controller specifically has that functionality built in.

So my question is whether or not I should use a kinematic rigidbody for my characters and find another means of controlling position…or is there a better way to avoid a physical effect of a collision from these other objects (maybe mass?).


So you are using Colliders on each object

  • You can set the collider to “Is Trigger”
  • Trigger will ignore collision and pass through objects
  • AND
  • Kinematic object won’t fall if for exemple there is no ground holding them
  • But you can move them by Script

No, a kinematic rigidbody isn’t the right choice here. A kinematic Rigidbody can’t detect any collisions. It can only send trigger messages or wake-up non kinematic rigidbodies so they can perform collision detection in case they were sleeping.

So you only have two options for a character that does collision detection:

  • Use a non kinematic rigidbody
  • Use the CharacterController instead.

The CharacterController actually don’t perform the usual collision detection as it rolls it’s own collision checks. So it doesn’t use the normal physics engine. The physics engine detects collision based on overlapping colliders. So when it detects an overlap it applies penalty forces to the objects involved to seperate them. The CharacterController uses some sort of raycasting to determine how far it can move and simply restricts movement in a direction where it collides.

There actually is a way to implement a similar behaviour with a Rigidbody, but it’s a bit more complicated. You could make your character a non-kinematic rigidbody and define a layer for the static level geometry and moving objects that should be able to push / move the player. All other objects should be on a different layer. Now just add a kinematic rigidbody as a child to your character. This child object should be on the other layer where the other rigidbodies are. This way your character can’t be pushed by those rigidbodies but your character will push them with the kinematic rigidbody child. Though this has some limitations / problems. If you for example push another rigidbody against a wall you run into a problem. That rigidbody either has to overlap with you (your kinematic rigidbody) or it is going to glitch through the wall. Since your character can move freely there’s nothing that stops him. The non-kinematic RB of your character simply doesn’t see those other object and just go through them.

Using the CharacterController would probably be easier, but it depends on your needs.