1
00:00:00,000 --> 00:00:00,000
Hello, guys.

2
00:00:00,000 --> 00:00:04,000
In this video, we're going to make this of the player and I just want to make function now.

3
00:00:04,000 --> 00:00:09,000
So later on, if we need we can just call it from the trap or from wherever we need.

4
00:00:09,000 --> 00:00:12,000
So it's all set and ready to use, right?

5
00:00:12,000 --> 00:00:16,000
First we need the boolean to kill the player and I don't want to create hell or just for that.

6
00:00:16,000 --> 00:00:20,000
So for now I'll create public bool is dead just here.

7
00:00:21,000 --> 00:00:23,000
Then I want to go to update.

8
00:00:24,000 --> 00:00:27,000
And say if.

9
00:00:27,000 --> 00:00:30,000
Is dead, then return.

10
00:00:30,000 --> 00:00:32,000
And I want to make it true if I need.

11
00:00:32,000 --> 00:00:38,000
So I'll copy this two lines of code, paste it in, and instead of K letter I will use.

12
00:00:38,000 --> 00:00:44,000
Oh, and instead of this function, I'll make new one which I'll call just die.

13
00:00:44,000 --> 00:00:49,000
Now I'll press alt enter and I can generate method.

14
00:00:50,000 --> 00:00:52,000
Now we have this function here.

15
00:00:53,000 --> 00:00:55,000
And what we can do is we can set.

16
00:00:55,000 --> 00:00:58,000
Is that true?

17
00:00:58,000 --> 00:01:00,000
We can knock back player a bit.

18
00:01:00,000 --> 00:01:07,000
So it's going to be RB velocity equals to knock back direction and we can set boolean to true.

19
00:01:07,000 --> 00:01:12,000
So anim set ball is that to true?

20
00:01:12,000 --> 00:01:19,000
Right now let's go to Unity and set up animation going to select player animation, create new clip

21
00:01:19,000 --> 00:01:20,000
player die.

22
00:01:20,000 --> 00:01:28,000
Now we can go to graphics, find this knockback and take second Sprite up to fifth Sprite.

23
00:01:28,000 --> 00:01:35,000
Drag it here and I want to make him hang in the air for a bit, so maybe I'll pull this two to the right.

24
00:01:35,000 --> 00:01:38,000
So this sprite will be there for two frames.

25
00:01:38,000 --> 00:01:40,000
Now let's change sample rate to 12.

26
00:01:43,000 --> 00:01:51,000
So I guess now we can go to animator behind this animation player die, set it somewhere from the right

27
00:01:51,000 --> 00:01:56,000
side and from any state we go into player die condition.

28
00:01:57,000 --> 00:01:58,000
We didn't create it.

29
00:01:58,000 --> 00:01:59,000
We need to do it.

30
00:01:59,000 --> 00:01:59,000
Create.

31
00:01:59,000 --> 00:02:02,000
Boolean is dead.

32
00:02:02,000 --> 00:02:03,000
Let's drag it above.

33
00:02:05,000 --> 00:02:06,000
Condition.

34
00:02:06,000 --> 00:02:07,000
Is that true?

35
00:02:07,000 --> 00:02:11,000
Transmission duration zero can transmit to self and check.

36
00:02:11,000 --> 00:02:19,000
And we need to make sure if we go to this animation, we're not transferring to any other from any state

37
00:02:19,000 --> 00:02:21,000
because this one still will be any state.

38
00:02:21,000 --> 00:02:21,000
Right.

39
00:02:21,000 --> 00:02:26,000
So let's go to this condition and add another one is that should be false.

40
00:02:27,000 --> 00:02:28,000
Same for the knockback.

41
00:02:32,000 --> 00:02:33,000
All right.

42
00:02:33,000 --> 00:02:34,000
I guess we all set.

43
00:02:35,000 --> 00:02:38,000
There is still something to do, but I want to do it step by step.

44
00:02:38,000 --> 00:02:41,000
Now, if I press my old letter, I should die.

45
00:02:42,000 --> 00:02:43,000
Boom.

46
00:02:44,000 --> 00:02:46,000
Okay, so there is two issues we need to fix.

47
00:02:46,000 --> 00:02:48,000
First one is animation.

48
00:02:48,000 --> 00:02:49,000
It is looped.

49
00:02:49,000 --> 00:02:53,000
So let's go to animations, find the player die, and then check loop time.

50
00:02:54,000 --> 00:02:57,000
And second, you saw a player is still moving when I died.

51
00:02:57,000 --> 00:02:59,000
So that is not okay.

52
00:02:59,000 --> 00:03:02,000
I guess he should be pushed back just for a bit and then he should stop.

53
00:03:02,000 --> 00:03:03,000
Check this out.

54
00:03:04,000 --> 00:03:11,000
So what we do is we're going back to code and we can create code routine again instead of just function.

55
00:03:12,000 --> 00:03:14,000
You remember how we did it in the knockback?

56
00:03:15,000 --> 00:03:15,000
Yeah.

57
00:03:15,000 --> 00:03:19,000
So instead of void, let's do a enumerator.

58
00:03:21,000 --> 00:03:24,000
And then here we're going to do.

59
00:03:25,000 --> 00:03:26,000
Yields.

60
00:03:28,000 --> 00:03:30,000
Return new.

61
00:03:30,000 --> 00:03:32,000
Wait 4 seconds.

62
00:03:32,000 --> 00:03:35,000
I guess point five is okay.

63
00:03:35,000 --> 00:03:41,000
And after that we're going to do RB dot velocity equals to new vector to zero zero.

64
00:03:41,000 --> 00:03:48,000
Now we need to go above and type here, not die, but start core routine.

65
00:03:49,000 --> 00:03:50,000
Start core routine.

66
00:03:51,000 --> 00:03:52,000
They.

67
00:03:53,000 --> 00:03:56,000
Okay, let's go back and see this.

68
00:04:02,000 --> 00:04:03,000
And boom.

69
00:04:04,000 --> 00:04:05,000
All right.

70
00:04:05,000 --> 00:04:07,000
And now, oh, we still can die.

71
00:04:09,000 --> 00:04:10,000
But we cannot jump.

72
00:04:10,000 --> 00:04:11,000
We cannot move.

73
00:04:11,000 --> 00:04:12,000
But we can die again and again.

74
00:04:12,000 --> 00:04:15,000
I'm sure it won't be triggered in the game again and again.

75
00:04:15,000 --> 00:04:19,000
But just in case, let's protect our self.

76
00:04:19,000 --> 00:04:25,000
Let's go and make sure we can do this only if we press button and not is dead.

77
00:04:27,000 --> 00:04:28,000
Okay.

78
00:05:08,000 --> 00:05:14,000
And boom, if you think he's moving not long enough, we can just increase the volume and it will be

79
00:05:14,000 --> 00:05:15,000
there.

80
00:05:15,000 --> 00:05:16,000
Where is it?

81
00:05:16,000 --> 00:05:17,000
Here.

82
00:05:17,000 --> 00:05:18,000
We can put one second.

83
00:05:18,000 --> 00:05:19,000
For example.

84
00:05:19,000 --> 00:05:19,000
One.

85
00:05:21,000 --> 00:05:23,000
Let me see if I can find any other bugs.

86
00:05:24,000 --> 00:05:26,000
I'm going to press all the buttons we have.

87
00:05:36,000 --> 00:05:37,000
Can I knock him?

88
00:05:37,000 --> 00:05:38,000
Yes, I can.

89
00:05:38,000 --> 00:05:39,000
I can do knock back.

90
00:05:40,000 --> 00:05:42,000
You know how to fix that, right?

91
00:05:42,000 --> 00:05:43,000
I'm going to give you a couple of seconds to try.

92
00:05:43,000 --> 00:05:44,000
Do it yourself.

93
00:05:45,000 --> 00:05:47,000
One, two.

94
00:05:47,000 --> 00:05:47,000
Okay.

95
00:05:47,000 --> 00:05:49,000
So once we die, we should set.

96
00:05:49,000 --> 00:05:51,000
Can be knocked to false.

97
00:05:52,000 --> 00:05:53,000
It can be knocked false.

98
00:05:54,000 --> 00:05:55,000
Okay, We done here.

99
00:05:55,000 --> 00:05:57,000
Let's go to next video.

