How can i add collision to top down 2d walls?

Im trying to figure out how to add collisions to the walls in my game, i read that at least one object usually has a rigid body 2d, so i added it to my player character but it makes my character zoom downwards off screen, even when i change the size of the box collider of the background so the player character is not inside it. I don’t know what to do.

Rigidbodies will by default have gravity applied in the -Y (downward) direction. In a top-down 2D game, usually you have no use for such gravity due to the perspective. So on the Rigidbody you can set the Gravity Scale to 0.

Since your walls will most likely not move, you can simply add a non-trigger BoxCollider2D component to them. Your player, enemies, and NPCs should probably have a dynamic Rigidbody2D component on them, along with their own non-trigger BoxCollider2D/other 2D collider.

Not sure what you mean by “zoom downwards,” but like jeffreyschoch said, you want to set the gravity to 0 and probably check “freeze rotation” under the Rigidbody2D’s constraints.

1 Like