1
00:00:00,000 --> 00:00:00,000
Hello, guys.

2
00:00:00,000 --> 00:00:02,000
In this section, we're going to improve character.

3
00:00:02,000 --> 00:00:06,000
As I told you in the beginning of the course, we're going to make layers for the game.

4
00:00:06,000 --> 00:00:07,000
And that's what we did actually.

5
00:00:07,000 --> 00:00:12,000
First, we created Simple character, then we created simple platform and load generation.

6
00:00:12,000 --> 00:00:13,000
Then we created a background.

7
00:00:13,000 --> 00:00:17,000
Now we're going to improve character, then we're going to improve platforms and so on and so on and

8
00:00:17,000 --> 00:00:17,000
so on.

9
00:00:17,000 --> 00:00:22,000
And as I said, let's do character first because this probably most important.

10
00:00:22,000 --> 00:00:23,000
All right?

11
00:00:23,000 --> 00:00:26,000
So what I want to make in this video is a double jump.

12
00:00:26,000 --> 00:00:31,000
Let's go to the code of the player and we're going to do very minor changes here.

13
00:00:31,000 --> 00:00:40,000
First, let's go over here and create a boolean private bool can double jump right this all what we

14
00:00:40,000 --> 00:00:41,000
need basically for now.

15
00:00:41,000 --> 00:00:46,000
Then I'm going to go to our check input over here and I want to change it a bit.

16
00:00:46,000 --> 00:00:53,000
First, I want to take this line of code, click alt, enter and make method out of this.

17
00:00:53,000 --> 00:00:58,000
So we're going to do extract method and I'm going to name it as jump button.

18
00:00:58,000 --> 00:01:03,000
We need it like that because later we're going to use same function for mobile controls, but they're

19
00:01:03,000 --> 00:01:04,000
going to be later.

20
00:01:04,000 --> 00:01:04,000
All right.

21
00:01:04,000 --> 00:01:12,000
So now let's take this is grounded and just delete it from here and then we're going to go to jump button

22
00:01:12,000 --> 00:01:15,000
and type if is grounded.

23
00:01:16,000 --> 00:01:19,000
Then we jump like that.

24
00:01:19,000 --> 00:01:19,000
Oh, sorry.

25
00:01:19,000 --> 00:01:21,000
I lost my ear.

26
00:01:21,000 --> 00:01:24,000
Then we jump like that, and we're going to make a double jump.

27
00:01:25,000 --> 00:01:26,000
Equals true.

28
00:01:26,000 --> 00:01:28,000
Then we're going to make elseif statement.

29
00:01:28,000 --> 00:01:30,000
Else if.

30
00:01:30,000 --> 00:01:35,000
So basically, if somebody pressed John Button and player is not on the ground, we're going to go further

31
00:01:35,000 --> 00:01:36,000
to this code.

32
00:01:36,000 --> 00:01:40,000
And in here we're going to check if can double jump true.

33
00:01:40,000 --> 00:01:44,000
Then let's just duplicate this line of code over here.

34
00:01:46,000 --> 00:01:48,000
And we're going to set can double jump to false.

35
00:01:48,000 --> 00:01:54,000
So if it was called for once we set cannibal jump to true and we cannot use this if statement anymore.

36
00:01:54,000 --> 00:01:56,000
And basically it's going to work only once.

37
00:01:56,000 --> 00:02:01,000
And then when we lend it and we jump from the ground, we're going to set can double jump to true and

38
00:02:01,000 --> 00:02:03,000
we can do double jump again.

39
00:02:03,000 --> 00:02:05,000
And let's go and see that.

40
00:02:05,000 --> 00:02:06,000
Let's go back to unity.

41
00:02:06,000 --> 00:02:08,000
What I want to do before testing.

42
00:02:08,000 --> 00:02:14,000
I want to open, rigid body and set gravity scale to maybe, I don't know, five and jump fours.

43
00:02:14,000 --> 00:02:15,000
Let's make it 18.

44
00:02:16,000 --> 00:02:19,000
There's going to make a player heavier.

45
00:02:20,000 --> 00:02:22,000
But if you want, you can tweak this parameters.

46
00:02:22,000 --> 00:02:23,000
So let's go how it feels.

47
00:02:23,000 --> 00:02:26,000
I think that's OC more dynamic.

48
00:02:26,000 --> 00:02:33,000
You can make it like gravity skill more maybe six and Jump Force 22 to make him like that.

49
00:02:33,000 --> 00:02:37,000
Actually it feels nice, but let's keep it like that.

50
00:02:37,000 --> 00:02:39,000
So watch this.

51
00:02:39,000 --> 00:02:44,000
I can jump one time from the ground and if I press double jump, I can jump again.

52
00:02:45,000 --> 00:02:48,000
But if I press it a couple of times, I cannot do that.

53
00:02:48,000 --> 00:02:52,000
So only double jump works, which is cool, I guess.

54
00:02:52,000 --> 00:02:58,000
Right now I want to make animation for double jump to make it look better.

55
00:02:58,000 --> 00:02:59,000
Let's go.

56
00:02:59,000 --> 00:03:05,000
And I lost my animation window somewhere, so let me go to window animation.

57
00:03:05,000 --> 00:03:09,000
Animation, drag it here and we're going to create new clip.

58
00:03:10,000 --> 00:03:11,000
Animations.

59
00:03:12,000 --> 00:03:13,000
Player.

60
00:03:14,000 --> 00:03:15,000
Double jump.

61
00:03:16,000 --> 00:03:17,000
Save it.

62
00:03:17,000 --> 00:03:19,000
Let's go to project.

63
00:03:20,000 --> 00:03:22,000
Graphics player.

64
00:03:22,000 --> 00:03:26,000
There is a front flip animation and we're going to take it.

65
00:03:26,000 --> 00:03:28,000
But not everything.

66
00:03:28,000 --> 00:03:30,000
Let's see from the fifth sprite till the last one.

67
00:03:30,000 --> 00:03:32,000
I'm not sure how it's going to look.

68
00:03:32,000 --> 00:03:35,000
And I'll set sample rate to 25.

69
00:03:38,000 --> 00:03:39,000
Quite fast.

70
00:03:39,000 --> 00:03:40,000
Let me try.

71
00:03:40,000 --> 00:03:41,000
18.

72
00:03:42,000 --> 00:03:44,000
Now we need to see it in action.

73
00:03:44,000 --> 00:03:44,000
All right.

74
00:03:46,000 --> 00:03:47,000
Okay, cool.

75
00:03:47,000 --> 00:03:55,000
What I want to do next is to go to assets animations, find this player double jump and uncheck loop

76
00:03:55,000 --> 00:03:57,000
time, so it will be played only once.

77
00:03:58,000 --> 00:04:01,000
Now we're going to go to animator.

78
00:04:01,000 --> 00:04:03,000
We have this player double jump.

79
00:04:03,000 --> 00:04:06,000
Just want to change the name with a capital letter.

80
00:04:06,000 --> 00:04:13,000
Just for some reason I want to do it and we're going to do transition from jump fold to double jump

81
00:04:13,000 --> 00:04:20,000
if and we need to create a parameter here, boolean and double jump.

82
00:04:21,000 --> 00:04:22,000
Arm with upwards.

83
00:04:22,000 --> 00:04:28,000
So it will be first in the list so we can do it if can double jump.

84
00:04:28,000 --> 00:04:29,000
False.

85
00:04:29,000 --> 00:04:35,000
My logic here is that we transfer into this animation if we used double jump.

86
00:04:35,000 --> 00:04:38,000
So we cannot do double jump again and it's false.

87
00:04:38,000 --> 00:04:40,000
And we should transfer to double jump animation.

88
00:04:40,000 --> 00:04:41,000
Right.

89
00:04:42,000 --> 00:04:45,000
Exit time and check Duration zero.

90
00:04:47,000 --> 00:04:52,000
And then let's make another transition back to Idol move and check exit time.

91
00:04:52,000 --> 00:04:56,000
Duration zero and condition will be is grounded.

92
00:04:56,000 --> 00:04:57,000
True.

93
00:04:57,000 --> 00:04:58,000
All right.

94
00:04:59,000 --> 00:05:00,000
Now, that's not the end.

95
00:05:00,000 --> 00:05:02,000
We need to pass this value in the code.

96
00:05:02,000 --> 00:05:05,000
So let's go to player script again.

97
00:05:06,000 --> 00:05:10,000
Find animator and just type here anim said Bull.

98
00:05:12,000 --> 00:05:16,000
Ken, Double jump to Ken.

99
00:05:16,000 --> 00:05:17,000
Double jump.

100
00:05:17,000 --> 00:05:18,000
Just like that.

101
00:05:19,000 --> 00:05:24,000
Now it's going to work, but we're going to have one bug and I want to show it to you first.

102
00:05:24,000 --> 00:05:27,000
So, you know, you are ready for these kind of situations.

103
00:05:27,000 --> 00:05:28,000
So let's go to play mode.

104
00:05:30,000 --> 00:05:34,000
And I'm jumping one, two, and I'm not transferring.

105
00:05:34,000 --> 00:05:35,000
So why is that?

106
00:05:36,000 --> 00:05:40,000
It's happening because you can see in the animator I'm transferring to jump fall.

107
00:05:40,000 --> 00:05:44,000
And that happens because we can transfer the jump fall from any state.

108
00:05:45,000 --> 00:05:49,000
So what animator does is Let me try to do that.

109
00:05:53,000 --> 00:05:55,000
So what's happening here?

110
00:05:55,000 --> 00:06:01,000
We did transfer to double jump animation, but because we can transfer to jump fall from any state,

111
00:06:01,000 --> 00:06:04,000
we did transfer to jump fall again real quick.

112
00:06:04,000 --> 00:06:10,000
So what we need to do here is to select this condition and add can double jump True.

113
00:06:10,000 --> 00:06:13,000
So we can transfer here only if can double jump true.

114
00:06:13,000 --> 00:06:15,000
Now let's go and see that in the action.

115
00:06:16,000 --> 00:06:17,000
Boom, boom.

116
00:06:18,000 --> 00:06:19,000
They're a pretty right.

117
00:06:22,000 --> 00:06:27,000
No, I think animation could be slower, but I'll leave it for now because I want to see how I'm feeling

118
00:06:27,000 --> 00:06:29,000
about this later on in the game.

119
00:06:29,000 --> 00:06:31,000
But now it's quite dynamic.

120
00:06:31,000 --> 00:06:38,000
What I want to change here actually is the power of double jump because I don't like when player and

121
00:06:38,000 --> 00:06:42,000
even me personally uses double jump all the time.

122
00:06:42,000 --> 00:06:45,000
Like it's the main tool to go across the level.

123
00:06:45,000 --> 00:06:51,000
I like to use it like a stepping stone, like a small jump that can save you in difficult situations

124
00:06:51,000 --> 00:06:55,000
but won't be your main use, let's say.

125
00:06:55,000 --> 00:07:00,000
So for that, we're going to go to player again and we're going to create.

126
00:07:01,000 --> 00:07:03,000
Private float.

127
00:07:03,000 --> 00:07:05,000
Double jump horse.

128
00:07:05,000 --> 00:07:07,000
And I guess it should be sterilized field.

129
00:07:07,000 --> 00:07:08,000
Sterilized field.

130
00:07:09,000 --> 00:07:10,000
Let's move it up.

131
00:07:10,000 --> 00:07:12,000
And we're going to create one more value.

132
00:07:12,000 --> 00:07:14,000
Private float.

133
00:07:14,000 --> 00:07:15,000
Default.

134
00:07:15,000 --> 00:07:17,000
Jump Horse.

135
00:07:18,000 --> 00:07:24,000
Now we go to start function over here and we say default jump horse equals to.

136
00:07:25,000 --> 00:07:26,000
Jump force.

137
00:07:27,000 --> 00:07:28,000
That's good enough.

138
00:07:28,000 --> 00:07:35,000
Now let's go to John Button and when we press jump for the first time, we're going to make sure our

139
00:07:35,000 --> 00:07:38,000
jump force is equals to default jump force.

140
00:07:39,000 --> 00:07:44,000
But when we press double jump, we need to do jump.

141
00:07:44,000 --> 00:07:49,000
Force equals to double jump force just like that.

142
00:07:50,000 --> 00:07:51,000
Now let's go back to Unity.

143
00:07:52,000 --> 00:07:55,000
Find double jump force and set it to something lower.

144
00:07:56,000 --> 00:07:58,000
Maybe like 12.

145
00:07:59,000 --> 00:08:01,000
Let's go to play mode now.

146
00:08:01,000 --> 00:08:07,000
And I'm going to jump once and like a little hop over there.

147
00:08:07,000 --> 00:08:08,000
Maybe a bit more.

148
00:08:13,000 --> 00:08:13,000
Yeah.

149
00:08:13,000 --> 00:08:14,000
Cool.

150
00:08:14,000 --> 00:08:15,000
I think it's cool.

151
00:08:17,000 --> 00:08:19,000
I don't like that in the inspector.

152
00:08:19,000 --> 00:08:21,000
I see jump Force as a double jump force.

153
00:08:21,000 --> 00:08:24,000
So let's go and change something in the code just by a bit.

154
00:08:25,000 --> 00:08:27,000
We're going to move this line of code over here.

155
00:08:28,000 --> 00:08:32,000
So we're going to change it back to default right after we did the jump.

156
00:08:33,000 --> 00:08:34,000
Uh.

157
00:08:35,000 --> 00:08:35,000
Yeah.

158
00:08:35,000 --> 00:08:37,000
Now, it's always the same in the inspector.

159
00:08:39,000 --> 00:08:42,000
So this is good enough, I guess.

160
00:08:44,000 --> 00:08:46,000
Maybe higher.

161
00:08:47,000 --> 00:08:47,000
Yeah.

162
00:08:47,000 --> 00:08:49,000
Let's keep it at 13 for now.

163
00:08:49,000 --> 00:08:51,000
And maybe later we decide to change it.

164
00:08:52,000 --> 00:08:52,000
Maybe not.

165
00:08:52,000 --> 00:08:53,000
Who knows?

166
00:08:53,000 --> 00:08:54,000
It's, you know, it's never finished.

167
00:08:54,000 --> 00:08:57,000
You always said we are in developing process.

168
00:08:57,000 --> 00:09:00,000
We are testing and seeing how it feels.

169
00:09:00,000 --> 00:09:01,000
Good.

170
00:09:01,000 --> 00:09:06,000
Now let's go to code and see if we can clean up anything there at this moment.

171
00:09:07,000 --> 00:09:11,000
So I would like to move this over here and.

172
00:09:13,000 --> 00:09:14,000
And.

173
00:09:17,000 --> 00:09:18,000
Actually.

174
00:09:19,000 --> 00:09:22,000
Actually, there is a way to make it cleaner.

175
00:09:23,000 --> 00:09:24,000
I don't know.

176
00:09:24,000 --> 00:09:32,000
Why don't we just type here, double jump force instead of jump force and delete this and this.

177
00:09:33,000 --> 00:09:35,000
And this.

178
00:09:35,000 --> 00:09:37,000
And this.

179
00:09:38,000 --> 00:09:40,000
It was a bit silly of me, I guess.

180
00:09:40,000 --> 00:09:41,000
I don't know.

181
00:09:41,000 --> 00:09:47,000
I just used to have default value in for different purposes, just in case.

182
00:09:48,000 --> 00:09:49,000
This should work the same.

183
00:09:50,000 --> 00:09:52,000
And let me see something else in here.

184
00:09:57,000 --> 00:09:58,000
Yeah, it happens.

185
00:09:58,000 --> 00:10:02,000
Sometimes you don't see best solution at first and then you just.

186
00:10:03,000 --> 00:10:04,000
It appears to you.

187
00:10:04,000 --> 00:10:05,000
Happens with everyone.

188
00:10:05,000 --> 00:10:06,000
Right?

189
00:10:06,000 --> 00:10:07,000
I hope you can forgive me.

190
00:10:08,000 --> 00:10:09,000
Let me see if it works the same.

191
00:10:10,000 --> 00:10:11,000
Just supposed to.

192
00:10:12,000 --> 00:10:12,000
Yeah.

193
00:10:14,000 --> 00:10:14,000
Cold.

194
00:10:15,000 --> 00:10:16,000
Better and cleaner.

195
00:10:17,000 --> 00:10:18,000
Good.

196
00:10:18,000 --> 00:10:19,000
Good job, guys.

197
00:10:19,000 --> 00:10:20,000
Let's go to next video.

