Hi all, I am getting a very weird glitch. It’s kind of hard to explain, so I’ve just made a video to demonstrate.
Essentially, moving a GameObject around on its X axis in the editor pops the object BEHIND other objects, despite having a greater depth.
Any ideas?
Sprites use the painters algorithm per-object instead of using depth-testing per-pixel. That means objects are drawn from back to front, and the objects that are drawn last (the “front” objects) will draw OVER anything else that was drawn before it. So in this case, your camera thinks your player is moving behind your background, so it draws your background on top of the player.
My guess is that you’re using a perspective camera, which slightly moves vertices around to give things perspective (so objects up close appear bigger than objects far away). The perspective can slightly alter the depth as well, so if 2 objects are the same z-distance from the camera, the object that is closer to the camera on the X axis will have smaller depth then the other object.
Try changing your camera to Orthographic