- Home /
Object shown on top of another, rendering priorities?
I'm making a 2.5D game where textures are 2D but the placement is actually in 3D.
While in editor (both in game view and scene view) I saw part of the object of further distance gets rendered above those that are in front of it.
As you can see I have 3 textures on different axis (ISO on the left and pers on the right) and should be shown in order from left to right. See:
But in the editor, while viewing it from certain different perspective, part of the texture in the middle will over-cover the one in front of it. The rendering order is also wrong in the game view (little window with blue background at top left). See screenshots:
Why does this happen? Is there a way to set render priorities according to z axis? I only want to use one camera
Answer by Fattie · Apr 10, 2013 at 07:13 AM
the green boxes are colliders. are you using them for any reason? delete all colliders if you don't need them.
i can't see what's going on, but are they simply too close together? normally you just use a meter per layer for convenience in 2.5D. so the spaceships are at "1" and the clouds are at "2" etc etc.
So very simply give them a good separation (one meter each) to check it is not simply z-fighting since they are too close
Regarding your comments below
are you aware of orthographic view on the camera? Search on 100s of answers here or read the doc. Look at your camera. Click it. Look at the inspector. Select orthographic, not perspective. All 2.5D games are orthographic
very simply as a test, do this: Hit play. Now move the items further apart. Does it solve the problem, yes or no?
cheers
If your problem is solved pls click the TICK icon on the left, and don't hesitate to ask a new specific question.
Yeah, I'm using the button one for tile so player sprite can land on it, the other two is for triggers. I want to have multiple layers to achieve parallax scrolling effect, same texture appear at different distance will have show in different size in perspective few, so if I separate them too far they will be too small to see
I'm aware of arthographic camera but didn't use it since all layer will move at the same speed which defeat the purpose of parallas scrolling. Also I might want to do some "hack" in layer stage: assign normal map to some textures and add a light source so it casts selfshadow, I'm afraid in orthographic mode this will not work since I never get a chance to see the texture with light source from a different angle
After switching for orthographic view, the problem is gone in the game view but still exists in the scene view (consider they are really close tho). I will try your approach to separate then further For parallax scrolling is there a package you can recommand? Also do I need to make sprite smaller for each layer? (by scaling or creating mipmap if that's appropriate).
if you have new separate questions, close this question and ask new questions, many people will be pleased to help you
very simply
as a test,
do this: Hit play. Now move the items further apart. Does it solve the problem, yes or no?
Answer by dreammakersgroupAdmin · Apr 10, 2013 at 07:59 AM
if you are using transparent shader the object will be sorted in rendering from nearest to furthest, for some reason unity think object behind is nearest, please check the pivote of objects , each object pivote should be at center or bottom of the object
Your answer
Follow this Question
Related Questions
How to call Camera.Render from Update 1 Answer
RenderTexture captured from camera with post effects only shows the emission pass. 1 Answer
How to make a custom GrabPass-like sampler2D in MRT shader? 0 Answers
ClearFlags don't seem to work when I manually call Render() on my cameras. 0 Answers
Rendering a 3D object within a specific area/bound? 1 Answer