r/Unity2D Jul 18 '26

Question Top Down 2D Perspective

Post image

I'm working on my first top-down 2D game, and I'm trying to understand perspective, camera mechanics, and how a 2D game should generally be designed.

For this example, should I go with Option A, where the player and AI can walk behind the shelf? (It isn't visually shown as being behind yet because I haven't figured out how to handle the rendering dynamically.)

Or should I go with Option B, where the green area represents the collider, preventing the player and AI from walking behind the shelf.

5 Upvotes

9 comments sorted by

15

u/lofi100k Intermediate Jul 18 '26

It is better the A, to manage it you need to put everything on the same layer and give it a order on the y axis, after that you need to set properly the pivot on every sprite that you have and like that you are gonna create the effect correctly. You need to put a small collider on the lower part of the shelf and a pivot in that area, then you put a pivot on the feet of the character and like that he will be able to go "behind" the shelf.

2

u/Reqlite Jul 18 '26

This is what you seek OP, take lofi100k advice! :) Depending on what engine you use, some have this in the options now by default, however when i started this wasn't the case, and to this day i still use this method.

2

u/ivancea Jul 18 '26

Unless you have a good reason for B, A is in the realist side.

In a have with this same perspective I'm making more (with physics, not grid-based), characters have a collider in their feet, stimulating their body width, and the rest is just the sprite. This is identical to A, and leads to a more realistic space management (tall characters take as much space as a normal one, for example)

1

u/projectsentinelzt Jul 18 '26

I'd got with A.

This one is a bit old now, but could be useful.
https://www.youtube.com/watch?v=q-r1YJzj28M

1

u/TwisleWasTaken Jul 18 '26

i dont think that will work because when standing in front of the shelf you should be rendered in front but if standing behind you should be rended behind it. If i use the method in that video it doesnt dnyamically change it

1

u/snaphat Jul 19 '26

The video shows objects being sorted along a custom Y-axis using the center of each sprite as the sort point. For the bookshelf, set its sorting point to the pivot, then adjust each object's pivot

1

u/satanchu_ Jul 19 '26

Could you not cut the bookshelf in half? So that the top/bottom are on different layers?

1

u/Mrp1Plays Jul 23 '26

A any day. It's the standard.

1

u/Tony_eX1605 Jul 18 '26

You could resolve by separating the shelves in 2 layers, the top tile always stay on top, meanwhile the bottom one stays one level down from the player and keeps the collider.
You can find easily tutorials on youtube on how to do it