How to prevent the character controller sometimes passing through walls?

We have a character with movement, and it works nicely most of the time. It’s made up of unity’s CharacterController, our own input controller (in place of, for example, ThirdPersonController). This character happily moves around the level, and bumps into stuff and everything is apparently fine. Except…

Sometimes, the character slips through a collider. I can’t narrow this down much, as it happens so rarely. I’ve never seen it happen:

  • Through terrain
  • Through horizontal colliders

I most often see it happen:

  • Through my “invisible walls” (box colliders surrounding the level)
  • When running nearly parallel to a wall
  • When jumping at a wall
  • Where there are multiple colliders in close proximity

I suspect it may be related to the speed the character is moving (but the speed should should never be fast enough to step right through the collider in a Move)

Any help on this will be greatly appreciated!

Try attaching this script to your gameObject that has the character collider.

I encoutered the same situation this week and I think I’ve found the solution. I suppose that your charactercontroler center Z is not set to 0.

Mine was at .09 and I were able to go through most of my vertical collider when walking along and turning the camera.

After doing some tests, I found out that setting back the Z to 0 and now it doesn’t happen.

So just set it back to 0 and this should go alright.

If my english is bad please excuse me, i’m french speaking , I hope this will help.