Walls on Unity

I am making a level of my game, I must make the player not leave the environment with the walls, the wall has:

  1. Box Collider, trigger disabled

2.Static

The player

  1. Box Collider
  2. Rigibody Kinematic enabled.

Kinematic so that the player does not push me or make it rotate.

How do I make it work? So that the player crashes, does not go through the wall and is not pushed or altered.

For kinematic rigidbodies, use the MovePosition method.

The problem is that kinematic bodies don’t react to collisions, so they may be positioned anywhere, regardless of other colliders.

Rigidbodies react to collisions only if these conditions are met:

  • The rigidbody is not kinematic.
  • The rigidbody is moved using the AddForce methods exclusively (don’t modify the Transform, nor use MovePosition).