How do I prevent an object from going though the wall?

My player object has a Rigidbody on it. The mesh collider on the player is set as Convex. My terrain has a mesh collider on it, it is not set as Convex.

It seems if I move against the wall, and keep trying, eventually the player object goes through the wall. If I go much further I fall, endlessly.

I can’t set the terrain to Convex, as its not convex…

The Rigidbody on the player is se to Continuous Collision Detection and to Extrapolate for the Interpolate option.

How can I stop the player from going through walls?

Adjust the fixed and maximum allowed timestep.

I had this problem before. Problem was wrong approach to control the movements when dealing with rigid bodies . Use physics functions like Addforce or just simply change Velocity if you want rigid body to move don’t use transform functions , because overwrites physics engine values in next frame.

You may get better results using box colliders intead of mesh colliders…

I had a similar problem when my environment was full of mesh colliders that was solved by using simpler box colliders.