Rendering order of objects in different depths not correct.

Hello, I’m having problems with rendering objects in the correct order according to depth. Right now I have a script that will instantiate “Card” objects, which are simple Quad meshes with a texture. The script calculates their position and Z-axis rotation to arrange them in a “card hand” pattern.

What’s giving me problems is having the cards render in the correct order, in which the right-most card is at the back, and the left-most card is at the front. I tried to do this by making each card be 1 unity apart on the Z axis. However, this gives me the following result:

[15765-unity+2013-09-23+19-34-34-31.jpg|15765]

Only when I distance the cards by steps of 20 units in depth do I get the desired effect:

[15764-unity+2013-09-23+19-30-12-06.jpg|15764]

I was wondering why is it that separating the cards on steps of 1 unit in depth doesn’t create the same effect on rendering order. The problem with separating them by 20 units is that the sizes of the two edge cards are too different. It also creates this “spiral” type of pattern, rather than a clean circular pattern. Is there any other solution for this?

Thanks!

Thanks for the input guys. After searching a little bit more I found my problem in this thread.

I’m using a perspective camera since other objects in the scene are all 3D, the only 2D objects are the cards. As recommended in that thread, what I did to solve it is set

Camera.main.transparencySortMode = TransparencySortMode.Orthographic;

And set my card textures as transparent. That made them sort correctly by depth, producing the desired result. Thanks!