- Home /
Duplicate Question
Orthogonal view image cliping.
I am using an orthogonal camera for a 2d game.
I have two objects being spawned on a "floor" at the same height. The first object is a grey car that has a transform height(perpendicular to the camera) of .25 and the 2nd object is a yellow car with a height of 1.
Since the 2nd object is larger than the first object I would think that the 2nd object should occlude the first object
however as seen in the attached screen shot the smaller object is actually appearing through the larger object even though it is technically inside the 2nd object.
The arrow marked as number 1 demonstrates the smaller grey object clipping through the larger yellow object.
The arrow marked as number 2 demonstrates that the yellow object is in fact on top of the smaller grey object. Note that even if I am in the 3D perspective this phenomena occurs when looking at the object from the same top down perspective as the orthogonal view.
Any ideas on how to fix this? I need the colored cars to be visible as they are selectable by the player while the grey cars are just for show.
you must adjust the z axis of the objects. it's a very basic in making games. 100s of questions on here about it http://answers.unity3d.com/questions/473217/how-to-simulate-2d-layers-in-unity.html
Do you expect transparency to occlude? Because I think that is what you mean.
Fattie when you say adjust the z axis are you specifically talking about the location of the transforms origin or the transforms mesh? Right now the mesh of the yellow car is larger than the mesh of the grey car so it is technically above the grey car(so it closer to the camera), yet the grey car still shows through. Perhaps the renderer in unity only looks at the origin of the model when rendering an orthographic perspective but I doubt that. It could be something to do with the "transparent texture that I am using to get the alpha channel to work properly on my texture.
Also if I must change the location of the objects origin to be closer to the camera how do I do that while keeping the unit on the navmesh I have created since I am spawning these units dynamically from the same location and gravity pulls them against the ground?