As the title says im trying to render an object in front of others, i maneged to do it but i dont know how i could make the rendered object stay in a specified location, see images
what happens:
what i would like to achieve:
hierarchy:
So yeah the object renders in front of others, but not in a specified location obviusly
sorry for bad title, i dont know how to describe it
Three (3) primary ways that Unity draws / stacks / sorts / layers / overlays stuff:
In short,
The default 3D Renderers draw stuff according to Z depth - distance from camera.
SpriteRenderers draw according to their Sorting Layer and Sorting Depth properties
UI Canvas Renderers draw in linear transform sequence, like a stack of papers
If you find that you need to mix and match items using these different ways of rendering, and have them appear in ways they are not initially designed for, you need to:
identify what you are using
search online for the combination of things you are doing and how to to achieve what you want.
There may be more than one solution to try.
For instance, you may even use multiple co-located cameras to more-explicitly control apparent draw ordering.
Additional reading in the official docs:
And SortingGroups can also be extremely helpful in certain circumstances:
yeah but i dont have a problem rendering the object, i have a problem positioning the rendered object in a specific way, and it not even a problem its just me who cant do it.
I though that there could be two camera, they’re the same, but one renders only one thing(the target icon), so like they function the same but one renders only one layer
what do you mean by updating the 3d object?anyway i posted no code because there is no code for this thing.
The only piece of code regarding the lock object is this:
aimIcon.transform.position = new Vector3(targetPos.x, targetPos.y + 0f, targetPos.z);
All it does is transforming the object location above the currentTarget location( so above target’s head)
Thanks for the help you made me realize this, I notice that the more the camera is distant the closer to the ground the target will be, so now i’m gonna make a script that move the camera up and down based on the distance between the target and the camera