Hello, guys.
In this video I want to update heart icon that is in the in game UI that kind of represents if you have
extra life at the moment and if you can hit another trap before you die.
This heart over here.
So what we can do is go to in-game UI.
We need access to the player.
We can get it from game manager.
So what we're going to do is to create a component here.
Private player, player.
Then in the start we're going to say player equals to game manager.
Dot instance, dot player.
Very good.
Now let's go the player itself and create a boolean and the top somewhere here.
Something like I'll hide it in the inspector.
I don't want to see it public bool and that will say extra life.
All right.
So extra life.
If extra life is true, then we can get a hit.
Then let's go to update and just somewhere under the timer type extra life equals to more speed, bigger
or equals to max speed.
And let's find our damage function and change that.
We're going to say if extra life then knock back else start correcting to die.
And now, because this boolean is public, we can check it in the in-game UI.
And what I want to do here is to type interesting couple of lines of code.
We're going to type heart empty dot enabled equals to not player extra life.
So basically what it does look if extra life is true or not, extra life is false and then hard to empty
enabled going to be false.
If extra life set to false in the player script, then not extra life would mean true and then heart
empty would be enabled.
True.
You got me now.
Heart Full is going to be a bit easier to understand.
Enabled equals to player extra life.
This is much simpler, hard full enabled equals to true and this true going to be player extra life
true.
If player extra life is false, there's going to be set to false.
All right, let's go and see this hate play.
This is false.
Now I'll try to get maximum speed.
And we got it.
Red Heart.
All right, that's good enough.
Let's go to the next video and set up pause button.