Create a Lives Display in Unity

Showing current lives during the game

Objective: Create a lives display in the UI

Currently in the game the player has 3 lives but there is no way the user knows how many lives he has.

To create a live display first we’re gonna create a UI Image in the scene and assign the live sprite and modify the size and the position of the image.

Now in the UIManager script we gonna declare an array of sprites to have the reference for the sprites to show when the player loses s live, and another variable to have a reference to the image in the UI. Both references have to be assigned to the inspector.

Now we need a public function to update the lives display image in the UI and then in the player script we have to create a reference to the UI manager and call the function when the plater gets damaged.

As a result when we go to play mode we can see the current lives during the game.

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.