Creating the UI health bar
In the previous section, we introduced the first danger and hazard to the game: a zone that can damage and potentially kill the player. As a result, their health has the potential to reduce from its starting state. It's therefore useful both to us as developers and to gamers to visualize the health status. For this reason, let's focus on rendering the player's health to the screen as a UI health bar. Figure 6.25 offers a glimpse into the future, displaying the result of our work to come:
We'll start by configuring a canvas object that will contain our new UI.
Preparing the scene for the UI
To get started, we'll create and configure a canvas object and associated UI camera:
- Create a new UI Canvas in the scene (any scene) by choosing GameObject | UI | Canvas from the application menu. The newly created Canvas object represents the surface...