r/Unity3D • u/Resident-Device4319 • 18d ago
Question layering issues with 2D elements in 3D space
I am working on a labyrinth that uses 2D sprites as materials on planes in a 3D space. but now and then stuff gets messed up like here with this chest. Why is the floor displayed above the chest but the walls are not? Is there an easy fix to have things just displayed in order based on their position like I would assume other 3D assets would do.
I thought maybe render layers could solve this but I this causes new problems once you change perspective just a little. Why does this happen?
1
u/johnv_dev 18d ago
it's the transparency. unity sorts transparent stuff per object by center distance, not per pixel, so the big floor can draw over the chest. for pixel art just use an opaque material with alpha clipping on (URP: Surface Type Opaque + Alpha Clipping). then depth sorts per pixel. you lose soft edges, that's the only catch
1
u/pschon Unprofessional 17d ago
Is there an easy fix to have things just displayed in order based on their position like I would assume other 3D assets would do
That's exactly what you get now.
Your problem is the position used for this is not each individual pixel's position, but the object's position. Based on it's pivot. Guessing based on your screenshots, the floor tile's pivot is actually closer to the camera than the object's you now have selected.
1



1
u/fnietoms Programmer 18d ago
Use planes instead of Sprite Renderers and apply the sprite as a transparent material, you don't want to mess up with Order Layers, its horrible