Layering issue with gameobjects

I am making a 2d perspective game using unity and has many gameobject one behind another which are displacing in x axis. Now the problem here is that the gameobject which is ahead of another suddenly goes behind that.

For e.g. if there is one object at z = 3 and another at z = 3.2 than when i m moving the first object in x axis and when it is about to go out of the screen it moves behind the other gameobject.
can any one help me in this of why is this happening and how to solve it?

Thanks

I assume you’re using a shader that doesn’t write to the depth buffer.

okay. the shader m using is transperant/ bumped diffuse ( as i have to use alpha channel of the images).

You’re actually using a normal map?

I don’t see any reference for how to turn ZWrite on in a surface shader. It may be impossible. Considering what forum you’re in, and that you said “2d perspective” (don’t know what you mean by that exactly), though, I doubt you actually want to use that shader to begin with. I don’t know enough about what you need, to make a recommendation, though.

Hey thanks jessy for the replies. Actually m a beginner with 3d thus m not so into shader programming. However, after reading your 1st reply I read the unity shader docs and found out that cutout shaders can be used as my images are have full and no transparency, and it worked.
Thanks for the replies.