- Home /
2D Toolkit in 3D world
I've been checking out the 2D toolkit to use for mini-games within my world. I want to be able to put a 2D "game" in front of the 3D world as if someone had a journal or something in their hand, but can still look up and converse in the world.
I got it to work up to a point with the first person controller. It works all the way up until an object in the 3D world is closer to the camera than the sprite. Is there a way to force the sprite to always render on top? I've played with all the culling masks.
For this you'll probably need a shader that draws the 2D items over the top of everything else. I used to have a shader called 'TextOverlay' that would do this but cannot find it :(
Try searching for shaders, and post back your findings. I shall also keep looking and post back if successful, as I'm also after this for my 2D elements.
$$anonymous$$aybe try in the forums? : http://forum.unity3d.com/forums/16-ShaderLab
Or also check the shaders that come with UIToolkit or NGUI.
Thanks. I had some success by moving the UI items .02 away from the camera (had to resize the elements for this so not sure if I'm adding more CPU cycles or not) and expanding the bounding box on the character by .04 so that nothing could get in between the two. Shaders would be better as it would give me greater freedom in setting up the UI. But I wanted to share this as my "hack it to make it work for now" solution while looking for the correct way.
I'll look into what we can do with shaders.
Answer by belvita · Dec 01, 2013 at 08:36 AM
For this task
U must use orthographic camera and If u use fpc firs per cont...... U must disable the mouse look script inside character controller and u must Change the first person controller script also and delete the camera inside the fpc it takes 3 steps to turn the 3d environment to 2d like that.then u r ready to go easy.
Unfortunately you have misinterpreted the question. This is about depth sorting the elements drawn by 2 different cameras. If an object in the second camera is further away than an element in the first camera, the element in the first camera will be drawn over the element in the second camera. The only way I've come across to always have your second camera elements draw over every first camera element is to use a shader that takes priority and ignores depth sorting.