My team had characters with charactercontrollers on them who could walk through walls. The walls we use are cubes, scaled to x=30, y=1, z=30. They were sunk into the ground a couple units, so the character wasn’t slipping through underneath them. We only called charactercontroller.Move(Vector3) once per Update(), so that wasn’t the problem either.
Turns out the problem was caused two factors:
-
The character collider’s height was equal to or less than double its radius. For example, 6 height and 3 radius. Or even 5 height and 3 radius (which gets rounded up to 6 at run time).
-
The wall’s rotation was close to x=0, y=45, z=0. For some reason character didn’t slip through walls with a rotation of x=0, y=0, z=0.
Our solution was to increase the collider’s height slightly. For example, 6.1 height and 3 radius.
(Our best guess is that height=6 and radius=3 gives a perfect sphere, which only collides with the wall at a single point, and Unity didn’t register that every Update(). By increasing the height, that creates a cylindrical section in the middle of the collider, and that bumps into the wall at several points, making it easy for Unity to register it. Not sure why the 45-degree wall would make a difference.)