Objects that are behind others are rendering in front

I guess this belongs here even though I’m just using default graphical setting. I’m making a 2D game using a perspective projection, so I have the objects close together along the Z axis to avoid the parallax messing up the view. The problem is that at certain angles the depth doesn’t seem to matter, for example the gun rotates to point at the mouse, the gun is 0.1 closer to the camera, at certain angles the gun renders BEHIND the player. ( Some of these errors are occurring within the backgrounds as big as 2.9 units apart.) How do I fix this? In orthographic it works, but I want the parallax effect. What can I do?

1 Answer

1

Use an orthographic camera and fake the parallax effect by adjusting the size of these 2d elements in code.

Is there really no other way to fix this? Seems like a sizable issue. Like I said some of the distances are large and the bug still occurs.

–