Character Controller breaking through colliders

So I have run into a problem where the character controller can penetrate through box colliders and mesh colliders. This wouldn’t be that big of a deal except when it’s a wall that prevents the player from falling “through” the world.

I am using the iphone Camera Relative Controls prefab to control my character but if I push against a box collider or mesh collider for long enough or at the right angle, i can slowly get sucked through to the other side of the mesh. :frowning: Basically, the player can walk through walls.

I have adjusted the height, radius, slope limit, step offset, skin width of the Character Controller as mentioned in other threads and the documentation and I haven’t been able to find any solution. I have used different types of geometry to work around this problem and when the player doesn’t get sucked through, the player can “climb” up the geometry instead. So I end up with a character control that can walk through or climb over any collider in their way.

Is this a known bug because I cannot seem to find a workaround. Any tips or advice would be extremely appreciated.

Thank you in advance,

I think I figured it out. At the end of the “Camera Relative Constrol” script which is part of the iphone Camera Relative Controls prefab, I had extra code to allow the accerelometer to translate the player in the x axis.

I added an if statement at the end of the code below but that doesn’t seem to stop the player from moving into the wall if it is touching something but that doesn’t seem to work. Should I use a different function to detect where the character controller has collided with a box/mesh collider?

//new code for accelerometer
var dir : Vector3 = Vector3.zero;

dir.x = -iPhoneInput.acceleration.y;

// clamp acceleration vector to unit sphere
if (dir.sqrMagnitude > 1)
dir.Normalize();

dir *= Time.deltaTime;

// Move object in the x axis

if (character.collisionFlags != CollisionFlags.Sides)
transform.Translate (dir * speed);

You need to use the Move or SimpleMove functions for movement (rather than transform.Translate) to get the correct behaviour from the CharacterController.

Thank you!

However, when I used SimpleMove instead of transform.Translate to move the player in x-axis, it moved the player in in the global x-axis instead of the x-axis based on whatever direction the player is facing. Any ideas?