There are a few reasons why this could be happening. Firstly, ensure that all objects involved, including your player and the walls, have colliders attached to them. Unity's physics engine relies on colliders to detect and respond to collisions. If your objects lack colliders, they won't physically interact with each other.
Additionally, if you are moving objects using physics, be cautious of parameters like the max penetration value in the Physics settings. Incorrect settings can lead to objects passing through each other. Always double-check your physics settings to guarantee realistic interactions between objects.
Kinematic Rigidbody in Unity:
In Unity, a kinematic Rigidbody is a type of Rigidbody that doesn't respond to external physical forces or gravity. This means Unity will not apply any physics to the kinematic Rigidbody. It allows precise control over an object's movement without being influenced by forces like gravity.
Rigidbody in Unity:
Rigidbodies in Unity are components that enable GameObjects to react to real-time physics. When attached to a GameObject, Rigidbodies allow reactions to forces, gravity, mass, drag, and momentum. You can add a Rigidbody to your GameObject by clicking on Add Component and searching for Rigidbody2D in the Unity editor.
Kinematic Rigidbody 2D in Unity:
Kinematic Rigidbody 2D in Unity is specifically designed to be repositioned explicitly via Rigidbody2D methods. It moves using its velocity, but this velocity is not affected by external forces or gravity. To control the movement of a Kinematic Rigidbody 2D, use physics queries to detect collisions and scripts to decide how and where it should move.
Rigidbody in C#:
In C# scripting for Unity, the Rigidbody component can receive forces and torque, enabling your objects to move realistically. Any GameObject must have a Rigidbody attached to be influenced by gravity, respond to forces applied via scripts, or interact with other objects through Unity's physics engine.
Box Collider in Unity:
Colliders in Unity work in conjunction with Rigidbodies to simulate physics interactions. While Rigidbodies allow objects to be controlled by physics, Colliders enable objects to collide with each other. It's essential to note that Colliders must be added to objects independently of Rigidbodies. They define the shape of the object's collider, allowing Unity's physics system to accurately detect collisions and provide realistic responses.