- Home /
How to perform topdown 2D render order?
Hi,
I am quite new to Unity and as an exercise I am currently building a simple 2D topdown game in the style of the classic Legend Of Zelda games. My specific problem is now the handling of the render order between floor tiles, character and overlay sprites.
Example: I have a field of grass, my player sprite and a wooden fence. Because of the Zelda-style "fake", when my character stands directly in front of the fence, the character should be rendered in front of the fence. When standing directly behind the fence, the character should be rendered behind the fence.
is there any way I can implement this in Unity? I already googled similar problems and read things about shader tags, but none of this seemed to fall into my specific problem.
Answer by rutter · Jun 17, 2014 at 09:11 PM
First, you can divide your sprites into sorting layers. It sounds like you're already doing that, to break up background/foreground/etc.
Second, you can specify a sorting order within each layer. The higher an object's sorting order, the closer to the top of its layer it will be.
In your case, it sounds like you could adjust each object's sorting order as it moves. As an object moves north, the sort value decreases; as an object moves south, the value increases. Because of this, an object that is further south will render on top.
thanks! yes, i am already doing layer sorting. but specifying the sorting order sounds exactly like the thing i need to do
Your answer
Follow this Question
Related Questions
Procedural terrain- of the 2D circular variety. 0 Answers
2d game foreground image based on terrain shape 0 Answers
2D Procedural Terrain Generation + Pooling 2 Answers
2d fake 3d objects cheaper in terms of drawcalls/ performance? 1 Answer
Hi all,how to create a 2d terrain??I cant find the "Create 2d terrain". 1 Answer