3D hovering health bars

Making World Space UI in a 3D scene takes a little more work than making World Space UI in a 2D scene if the camera can be rotated and moved throughout the 3D space. If the camera can move and rotate, the UI likely needs to constantly face the camera. Otherwise, the player will not be able to see the UI Element.

For this example, we will once again create a new scene. For you to not have to build out the scene, we will start with an Asset package that includes all the required items.

We'll create a simple hovering health bar that constantly faces the camera. It will also receive clicks so that we can watch the health bar reduce:

The art used in this example was accessed from https://opengameart.org/content/space-kit ...

Get Mastering UI Development with Unity now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.