Hi all, i’m new to Unity and trying to build a 2D map but i’m having some trouble setting the correct order…
I thought that using Z as layer would have make unity draw the sprites with the correct overlapping but it doesn’t seem to work in some places…
In the editor window you can see that i set the sprites so that those which need to be drawn on top have lower Z, instead those which can be overlapped have higher Z.
You can also see that the wall is being drawn over a sprite with lower Z (why is that?!)
I’d like to know what i’m doing wrong and how to fix this, thanks!
(Camera is in ortographic mode)
Edit: i’m using Sprites/Default shader
you can just use unity sprite layer system. every sprite renderer component has a layer and order in layer.
fact is i'm not using sprites right now, this map is made as a combination of two meshes, one for the terrain and a second for the buildings.. Being the vertices of the "sprite" in the mesh with a lower Z shouldn't they be drawn on top of those with higher Z?
won't using sprites drop down performances? we are talking about 15k simultaneous sprites (that i currently collapse into a big mesh) Also, how do SpriteRenderer can render multiple sprites (i looked around but didn't find any solution.. but this is another question..!) Instead this are the visualization problems using the shader i posted (and that is disappeared.. Link: http://answers.unity3d.com/questions/582064/enable-sprite-depth-write.html ) the problem here is hat top rendered sprites "bypass" already rendered ones ![alt text][1] [1]: /storage/temp/19334-03bis.jpg
I too was having this issue and found that it was being caused by the Material on the Sprite Renderer. I had some which where “Sprites-Default” and others which were “Default-Diffuse”. Setting them all to the same fixed the issue for me.
I hope this helps.
i'm sorry i can't check it anymore, i left the project suspended due to other commitments :)
I had this problem with some 2d characters which I was animating within unity. Having the head stay on top of the chest, whilst being correct in relation to other characters, was a huge headache.
I used a multiple Z as the render layer and had them all stay in relation to the chest. So chest layer = chest.z. Head layer = Chest Layer +1. This kind of worked, but it was inconsistent and would swap around whenever I moved.
Anyway, it was solved after many lost hairs by swapping around the ‘fixed update/update’. I think I had the chest calculate on Update but the other parts that relied on it coming in the fixed update. Hope this helps someone.
you can just use unity sprite layer system. every sprite renderer component has a layer and order in layer.
– ziv03fact is i'm not using sprites right now, this map is made as a combination of two meshes, one for the terrain and a second for the buildings.. Being the vertices of the "sprite" in the mesh with a lower Z shouldn't they be drawn on top of those with higher Z?
– KonsYou should use sprites, then the sprite shader will work and you can use sorting layers, and order in layer.
– Eric5h5won't using sprites drop down performances? we are talking about 15k simultaneous sprites (that i currently collapse into a big mesh) Also, how do SpriteRenderer can render multiple sprites (i looked around but didn't find any solution.. but this is another question..!) Instead this are the visualization problems using the shader i posted (and that is disappeared.. Link: http://answers.unity3d.com/questions/582064/enable-sprite-depth-write.html ) the problem here is hat top rendered sprites "bypass" already rendered ones ![alt text][1] [1]: /storage/temp/19334-03bis.jpg
– Kons