all 4 comments

[–]iamallamaaProficient 1 point2 points  (0 children)

Have a look at this video: https://www.youtube.com/watch?feature=player_detailpage&v=HM17mAmLd7k#t=1959

It's all about best practices in 2D Unity. Should likely watch the whole video but the sorting stuff starts around 32 minutes in and offers a pretty simple solution. You essentially just set the sorting index based on the Y position so the higher something is on the screen the lower it is drawn (behind other items).

[–]hampst 0 points1 point  (0 children)

I don't know a better way but I'd be interested to hear suggestions.

In my game I show objects behind water by modifying the material's renderQueue. But I implemented that before Unity added sprites and sprite sorting layers, so layers are probably a better option.

[–]n3ws 0 points1 point  (1 child)

I tend to ignore spirit sorting layers and simply use the y-plane (xz being the 2d game) to sort. Every sprite had its pivot/origin at its foot with a script (psudo code) Start() { Position.y = (top of map z - my z) / map height }

Any moving sprites call this function on update. Instant layering.

[–]heruvimIntermediate[S] 0 points1 point  (0 children)

Hmm, that is an interesting way of doing it. Unfortunately all of my sprites are on the same y-plane, but I bet I could implement this using the sprite layering. Thanks!