How to get collisions to work?

I’m making a 2D top down RPG style game (think Legend of Zelda) and need to make it so that the character cannot pass through the walls. I put box colliders on the player and the walls but the player still goes through the colliders on the walls. Does anybody know how to fix this?

Rigidbodies make bodies obey physics but collisions are via Colliders. Check your Physics2D settings in Project Settings, particularly the Layer Collision Matrix. Then check the layers of your player and the walls.

Also make sure your Collider component has IsTrigger unchecked. A trigger will just register a collision but the collider won’t expel the other collider.

Yeah, like @RodrigoAbreu said, you need rigid bodies. But make sure to freeze the rigid body’s positions and rotations and turn isKinematic off.

I don’t know why this happened (maybe some of you do) but after trying all of the answers, it still didn’t work until I removed all the colliders and rigid bodies and forgot to freeze the position and rotation on the rigid body and suddenly, it worked! Turns out I needed to unfreeze the positions on the rigid body!