How to constrain player in a level?


In my game, which will be 2D eventually but I’m prototyping in 3D as of now, I want to limit the player into the game’s world so he or she cannot get outside the level.

What I did is I put 4 cubes around the level so when player reaches them, it would stop him.

Problem is no matter how I move my character, either with CharacterController or adding RigidBody and moving him with Forces, when player reaches those boundries and presses against them, he would slide!

How I can stop this from happening?

And better, what would you suggest in order to limit the player from going outside of the level?

Here is screenshot of my scene:

If the level bounding boxes have rigidbodies, you can go on it ‘freeze’ its position and rotation on all axis. (You find these options on the rigidbody component itself)