- Home /
How To Make Floating Combat Text In new UI System of 4.6
Hi, I'm working on a top-down action game. Using the new UI system of Unity4.6, I need to display some text in the game scene like player's name and health bar over their models, damage and healing numbers over their bodies. These texts should be fit with the model positions in 3d axis, not pinned in screen position. Which means when the camera is moving, you should see the texts are still attached to what it should be with in the game world. And the texts should be facing the camera, visually it feels like a 2d GUI. It shouldn't overlap or be blocked by 3d models in the game. I try two options: 1, use the text GUI in screen space canvas, and adjust their positions by the camera.WorldToScreenPoint in the update function. It does work though but looks a little bit delayed and shaking when they are set every frame. 2, use the world space canvas and text in 3d world, but they often get overlapped by the models. So how I deal with this problem.
Answer by SkaredCreations · Dec 18, 2014 at 12:39 PM
I think world space canvas is the right way, if the models overlap the easiest way to workaround is to assign for example layer UI to your canvas (and children), create a second camera parented to the main camera (at its origin) with higher Depth and set its Clear Flags as Depth Only and Culling Mask only UI (remove the layer UI from the culling mask of the main camera).