Day 91: Player Lives Part 3.

Tyler Smallwood
2 min readNov 17, 2021

--

Objective: Add a system to update the Players Live count on the UI.

In the past, we created a system to update the coins UI with a singleton pattern that can be found here:

We will use the same system for the lives. We will open up our UIManager script and create a UpdateLivesCount method that takes an int.

We will now create a Text Mesh Pro Text variable called lives.

Inside our method, we will assign the _livesCount to equal the int that got passed in.

Now in the Player Script we will call the UIManager and pass in the lives count.

In Unity under our Canvas object we will copy the Coin text and just change to Lives.

All that’s left to do is assign the Lives_Text to the Canvas UIManager script.

And that all there is for the Player Lives system. We can update the Lives count and cause damage to the player.

Thank you for reading and have a wonderful day!!

--

--

Tyler Smallwood
Tyler Smallwood

Written by Tyler Smallwood

I am passonate on learning to program and use Unity to become a skillful Unity Developer

No responses yet