1
00:00:00,000 --> 00:00:00,000
Hello, guys.

2
00:00:00,000 --> 00:00:06,000
In this video I want to update heart icon that is in the in game UI that kind of represents if you have

3
00:00:06,000 --> 00:00:10,000
extra life at the moment and if you can hit another trap before you die.

4
00:00:10,000 --> 00:00:12,000
This heart over here.

5
00:00:12,000 --> 00:00:16,000
So what we can do is go to in-game UI.

6
00:00:17,000 --> 00:00:19,000
We need access to the player.

7
00:00:19,000 --> 00:00:21,000
We can get it from game manager.

8
00:00:21,000 --> 00:00:24,000
So what we're going to do is to create a component here.

9
00:00:25,000 --> 00:00:28,000
Private player, player.

10
00:00:29,000 --> 00:00:33,000
Then in the start we're going to say player equals to game manager.

11
00:00:33,000 --> 00:00:35,000
Dot instance, dot player.

12
00:00:36,000 --> 00:00:37,000
Very good.

13
00:00:37,000 --> 00:00:43,000
Now let's go the player itself and create a boolean and the top somewhere here.

14
00:00:43,000 --> 00:00:46,000
Something like I'll hide it in the inspector.

15
00:00:46,000 --> 00:00:52,000
I don't want to see it public bool and that will say extra life.

16
00:00:52,000 --> 00:00:52,000
All right.

17
00:00:52,000 --> 00:00:53,000
So extra life.

18
00:00:53,000 --> 00:00:56,000
If extra life is true, then we can get a hit.

19
00:00:56,000 --> 00:01:06,000
Then let's go to update and just somewhere under the timer type extra life equals to more speed, bigger

20
00:01:06,000 --> 00:01:08,000
or equals to max speed.

21
00:01:09,000 --> 00:01:11,000
And let's find our damage function and change that.

22
00:01:11,000 --> 00:01:16,000
We're going to say if extra life then knock back else start correcting to die.

23
00:01:16,000 --> 00:01:20,000
And now, because this boolean is public, we can check it in the in-game UI.

24
00:01:21,000 --> 00:01:26,000
And what I want to do here is to type interesting couple of lines of code.

25
00:01:26,000 --> 00:01:35,000
We're going to type heart empty dot enabled equals to not player extra life.

26
00:01:35,000 --> 00:01:42,000
So basically what it does look if extra life is true or not, extra life is false and then hard to empty

27
00:01:42,000 --> 00:01:45,000
enabled going to be false.

28
00:01:45,000 --> 00:01:51,000
If extra life set to false in the player script, then not extra life would mean true and then heart

29
00:01:51,000 --> 00:01:52,000
empty would be enabled.

30
00:01:52,000 --> 00:01:53,000
True.

31
00:01:53,000 --> 00:01:55,000
You got me now.

32
00:01:55,000 --> 00:01:58,000
Heart Full is going to be a bit easier to understand.

33
00:01:58,000 --> 00:02:02,000
Enabled equals to player extra life.

34
00:02:02,000 --> 00:02:08,000
This is much simpler, hard full enabled equals to true and this true going to be player extra life

35
00:02:08,000 --> 00:02:09,000
true.

36
00:02:09,000 --> 00:02:12,000
If player extra life is false, there's going to be set to false.

37
00:02:12,000 --> 00:02:16,000
All right, let's go and see this hate play.

38
00:02:16,000 --> 00:02:17,000
This is false.

39
00:02:17,000 --> 00:02:20,000
Now I'll try to get maximum speed.

40
00:02:22,000 --> 00:02:23,000
And we got it.

41
00:02:23,000 --> 00:02:24,000
Red Heart.

42
00:02:24,000 --> 00:02:26,000
All right, that's good enough.

43
00:02:26,000 --> 00:02:28,000
Let's go to the next video and set up pause button.

