- Home /
Rendering order approach for a 2.5D game.
First of all, I'm sorry if answers.unity isn't the place meant for this kind of questions or if it is posted on the wrong space.
I'm creating a tile-based 2.5D game and I want the lower tiles to be rendered after the top ones, so it looks like the player is in front of an object (refer to the screenshot). Currently I'm doing it by modifying the render queue when the player is over the object's Y axis but that obviously leads to a lot of bugs. How should I do that?
Thanks.
Answer by FlaSh-G · Sep 22, 2021 at 08:25 AM
This should help: https://docs.unity3d.com/2020.3/Documentation/Manual/2DSorting.html Especially the custom transparency sort axis makes this very easy.
Thanks, I'm going to try that. Just keep in $$anonymous$$d that since I'm really new to unity it may take me some $$anonymous$$utes.
It is half working. The tree renders under the player only when the player passes half of the sprite size. Is that because of some kind of reference point (pivot)?
Yes! I see you've found out by yourself by now. Make sure your pivots are all on the "ground" of the sprite - the feet, the center of the tree's circle that touches the ground, etc.
Answer by Tinho205 · Sep 22, 2021 at 05:11 PM
For future people who have the same problem, HERE is the solution: https://answers.unity.com/questions/1626564/transparency-sort-axis-on-y-with-pivot-instead-of.html
Transparency Sort Mode to: Custom Axis; Transparency Sort Axis to: X:0, Y:1, Z:0; All your sprite pivot's to: Bottom; On the sprite renderer of each sprite set "Sprite Sort Point" to "Pivot".
That should fix your error.
Also, changing the pivot of the player also changes the point to wich the camera aims, so change the offset of the camera for fixing that.