2D Toolkit Sprites, Incorrect Drawing Order

Hello. I’m a beginner at Unity, and I have a problem with the drawing order of sprites generated with the 2D Toolkit. I’m not sure if the toolkit has something to do with it. My problem is that sprites sometimes do not get drawn in their correct z order. I just set a scene, with a couple of sprites in the back, a platform and slope in the middle, and a couple of more boxes in the front. To explain:

I was just playing around and learning with one of the toolkit’s demo scenes. However when I run the game this always happens when I move the camera (by moving the player character). At certain positions the sprites are drawn in the correct order, but a few steps with the character and they’re drawn incorrectly again. The camera is perspective, not ortho. This problem does not occur when I set it to ortho, but if it’s possible to solve this issue otherwise I’d like to keep it persp.

This is most likely a banality, but I couldn’t find an answer so please forgive meif it’s a noob issue. Any tips are appreciated. Thanks.

http://www.unikronsoftware.com/2dtoolkit/doc/2.00/tutorial/choosing_camera.html

You can place 2D Toolkit sprites within a 3D scene - they are simply Unity GameObjects after all. A perspective camera is often used to get “parallax” for free - items further away from the camera will need to be scaled up to match the size of the foreground items (hint: use the “1:1” button on the sprite to make them pixel perfect at the distance they are at)

Don’t forget to set Camera.transparencySortMode to Orthographic if you want your sprites to sort correctly in a perspective camera.

If you’re making a 2D game with a perspective camera, you might want to use TransparencySortMode.Orthographic sort mode so that objects are sorted based on distance along the camera’s view.