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 a large claim, and it's a bit complicated.

3
00:00:04,000 --> 00:00:05,000
In my opinion.

4
00:00:05,000 --> 00:00:10,000
It is hardest part of the course, but I'll walk you through it step by step, and you will know this

5
00:00:10,000 --> 00:00:11,000
mechanic top to bottom.

6
00:00:11,000 --> 00:00:14,000
So I'm sure it will be very simple to understand.

7
00:00:14,000 --> 00:00:16,000
Don't worry about that.

8
00:00:16,000 --> 00:00:21,000
So first let me delete all of the prototyping I did, and then I'm going to show it to you how we do

9
00:00:21,000 --> 00:00:22,000
it step by step.

10
00:00:22,000 --> 00:00:23,000
All right.

11
00:00:23,000 --> 00:00:24,000
I think I'm ready.

12
00:00:24,000 --> 00:00:26,000
So let's begin with simple.

13
00:00:26,000 --> 00:00:27,000
Let's just create animation.

14
00:00:27,000 --> 00:00:35,000
First, we're going to select the player animation, create a new clip, and it's going to be player

15
00:00:35,000 --> 00:00:37,000
ledge climb.

16
00:00:37,000 --> 00:00:40,000
All right, we have it now.

17
00:00:40,000 --> 00:00:43,000
Let's go to graphics, fine player.

18
00:00:44,000 --> 00:00:47,000
Let's climb and drag all of the sprites to the left.

19
00:00:48,000 --> 00:00:51,000
Let's try sample rate 15, see how it works.

20
00:00:52,000 --> 00:00:53,000
Um.

21
00:00:54,000 --> 00:00:54,000
No.

22
00:00:55,000 --> 00:00:55,000
Probably.

23
00:00:55,000 --> 00:00:57,000
Let's see how it will be in the game.

24
00:00:57,000 --> 00:00:59,000
If anything, we can fix it.

25
00:00:59,000 --> 00:01:02,000
Now, let's go to animations, find animation.

26
00:01:02,000 --> 00:01:09,000
Let's climb and check loop time over here, and we can go to animator setup animation.

27
00:01:09,000 --> 00:01:14,000
We need the boolean for that so I can climb.

28
00:01:15,000 --> 00:01:18,000
We're going to move it over here and there's going to be a bit different.

29
00:01:18,000 --> 00:01:22,000
We're going to transfer to a ledge, climb from any state.

30
00:01:23,000 --> 00:01:30,000
If can claim true and now can claim somewhere below, let's just drag it here to the top.

31
00:01:31,000 --> 00:01:35,000
Now, if you add conditions, it will be at the top so I can climb through.

32
00:01:36,000 --> 00:01:37,000
Let's go to settings.

33
00:01:39,000 --> 00:01:44,000
Exit time and check duration is zero and make sure to check and transit to self.

34
00:01:44,000 --> 00:01:45,000
It's very important.

35
00:01:45,000 --> 00:01:53,000
Now we can make another transition to idle move and this will be exit time one duration zero and no

36
00:01:53,000 --> 00:01:54,000
condition to exit.

37
00:01:54,000 --> 00:01:55,000
That's it.

38
00:01:56,000 --> 00:01:58,000
Basically, we're done for the animator.

39
00:01:58,000 --> 00:02:01,000
Now we can forget about it for the time being.

40
00:02:01,000 --> 00:02:03,000
And I want to explain a bit how it's going to work.

41
00:02:04,000 --> 00:02:10,000
So we're going to do edge detection, but we're not going to do it from the player script like we did

42
00:02:10,000 --> 00:02:11,000
before.

43
00:02:12,000 --> 00:02:18,000
If you remember, we have this check collision function where we do in all detection we need.

44
00:02:18,000 --> 00:02:20,000
But let's detection.

45
00:02:20,000 --> 00:02:21,000
I want to do from another object.

46
00:02:21,000 --> 00:02:23,000
I want to do it from the child object.

47
00:02:23,000 --> 00:02:26,000
We have a reason to that and you'll know it in a minute.

48
00:02:27,000 --> 00:02:32,000
Let's go all the way up and in the collision info I want to create public boolean.

49
00:02:33,000 --> 00:02:34,000
Bull.

50
00:02:35,000 --> 00:02:39,000
Ledge detect it, but I don't want to see it in the inspector.

51
00:02:39,000 --> 00:02:43,000
I just need it public so I can access it from another script.

52
00:02:43,000 --> 00:02:47,000
But I want to keep it hidden so it will be hiding the inspector over here.

53
00:02:48,000 --> 00:02:49,000
All right, cool.

54
00:02:49,000 --> 00:02:50,000
We can move it up here.

55
00:02:51,000 --> 00:02:53,000
And now let's create ledge detection first.

56
00:02:53,000 --> 00:02:56,000
I guess I changed my world check size.

57
00:02:56,000 --> 00:02:58,000
Check If it's the same to yours.

58
00:02:58,000 --> 00:03:01,000
-0.3 Now, you can fix it if you want.

59
00:03:01,000 --> 00:03:04,000
Now we're going to create empty object.

60
00:03:04,000 --> 00:03:07,000
I'm going to call it large check.

61
00:03:09,000 --> 00:03:17,000
We're going to add component new script, ledge detection, and we can go inside of this script.

62
00:03:17,000 --> 00:03:18,000
All right.

63
00:03:18,000 --> 00:03:23,000
So what we need for let's check, we need to know position and for the position we're going to use.

64
00:03:23,000 --> 00:03:24,000
Exactly.

65
00:03:24,000 --> 00:03:26,000
The child object itself.

66
00:03:26,000 --> 00:03:27,000
This one.

67
00:03:27,000 --> 00:03:28,000
Right.

68
00:03:28,000 --> 00:03:30,000
This is going to be our position for.

69
00:03:30,000 --> 00:03:30,000
Let's check.

70
00:03:30,000 --> 00:03:32,000
Then we need read use for check.

71
00:03:32,000 --> 00:03:35,000
So I serialize field private float.

72
00:03:35,000 --> 00:03:38,000
We can call it just radius and basically that's it.

73
00:03:38,000 --> 00:03:46,000
So first I want to draw gizmos so we can visualize it on draw gizmos Gizmos to draw wire sphere from

74
00:03:46,000 --> 00:03:50,000
transform position in a radius.

75
00:03:50,000 --> 00:03:51,000
Yes.

76
00:03:52,000 --> 00:03:53,000
Let's go and see this.

77
00:03:53,000 --> 00:04:01,000
We're going to increase radios to something like point two, and I want to place it somewhere above.

78
00:04:02,000 --> 00:04:08,000
Maybe right here, just like in front of the head of the player where?

79
00:04:08,000 --> 00:04:08,000
Let's check.

80
00:04:08,000 --> 00:04:10,000
Possibly it could be all right.

81
00:04:10,000 --> 00:04:11,000
So I think this is fine.

82
00:04:11,000 --> 00:04:13,000
Somewhere in front of the head.

83
00:04:13,000 --> 00:04:15,000
Don't worry about precise placement.

84
00:04:15,000 --> 00:04:17,000
It's not so important.

85
00:04:17,000 --> 00:04:19,000
So now we have let's check position.

86
00:04:19,000 --> 00:04:21,000
We know area we detected.

87
00:04:21,000 --> 00:04:23,000
Now it's time to create.

88
00:04:23,000 --> 00:04:28,000
Let's check itself and I don't want to create boolean here for edge detected.

89
00:04:28,000 --> 00:04:29,000
I want to use boolean.

90
00:04:29,000 --> 00:04:32,000
We just create it on the player which we made public.

91
00:04:32,000 --> 00:04:36,000
So let's go back to edge detection, get access to the player.

92
00:04:37,000 --> 00:04:41,000
Serialize field, Private player player.

93
00:04:41,000 --> 00:04:42,000
Sorry.

94
00:04:43,000 --> 00:04:51,000
And then in the update we're going to do player dot slash detected equals to physics to DX, and here

95
00:04:51,000 --> 00:04:52,000
it's all the same.

96
00:04:52,000 --> 00:04:55,000
You see, basically we do in what we did here check collision.

97
00:04:55,000 --> 00:05:00,000
Very same stuff just from another script and our lab circle.

98
00:05:02,000 --> 00:05:02,000
Right.

99
00:05:02,000 --> 00:05:05,000
Over lap circle.

100
00:05:06,000 --> 00:05:08,000
From transfer position.

101
00:05:09,000 --> 00:05:11,000
In the radius.

102
00:05:12,000 --> 00:05:20,000
Och now I want to go to player and just debug ledge, detect it, debug that log ledge, detect it.

103
00:05:21,000 --> 00:05:28,000
We need to say what is clear so we can just drag it like this and we're going to go to play mode.

104
00:05:28,000 --> 00:05:30,000
Oh, no, I forgot something important.

105
00:05:30,000 --> 00:05:31,000
Guys.

106
00:05:31,000 --> 00:05:33,000
We need a layer for this.

107
00:05:33,000 --> 00:05:33,000
Right.

108
00:05:34,000 --> 00:05:35,000
I hope you did notice before me.

109
00:05:35,000 --> 00:05:37,000
Serialize field pry.

110
00:05:37,000 --> 00:05:39,000
What layer mask?

111
00:05:39,000 --> 00:05:42,000
What is ground?

112
00:05:43,000 --> 00:05:43,000
Okay.

113
00:05:43,000 --> 00:05:45,000
And we're going to do check radius.

114
00:05:45,000 --> 00:05:47,000
And what is ground is a layer mask.

115
00:05:48,000 --> 00:05:50,000
Now, let's go back and check this.

116
00:05:58,000 --> 00:05:59,000
You're going to go to play mode.

117
00:06:00,000 --> 00:06:05,000
We need to choose what is ground and better do it out of play mode.

118
00:06:06,000 --> 00:06:09,000
So now we have console that says false.

119
00:06:09,000 --> 00:06:14,000
If I drag my ground like this to the circle now it says true only.

120
00:06:14,000 --> 00:06:20,000
And by the way, if your console looks like this, you can just click button collapse and it will collapse

121
00:06:20,000 --> 00:06:20,000
the messages.

122
00:06:21,000 --> 00:06:22,000
So now it is true.

123
00:06:22,000 --> 00:06:25,000
If I move it out, let me make it smaller.

124
00:06:25,000 --> 00:06:25,000
Right.

125
00:06:29,000 --> 00:06:31,000
So now let's just detect it.

126
00:06:31,000 --> 00:06:31,000
True.

127
00:06:31,000 --> 00:06:33,000
If I move it out, it is false.

128
00:06:33,000 --> 00:06:39,000
But what if we detect ledge like that when we face a long wall?

129
00:06:39,000 --> 00:06:40,000
Watch this.

130
00:06:40,000 --> 00:06:41,000
This is pretty long.

131
00:06:41,000 --> 00:06:42,000
All right.

132
00:06:42,000 --> 00:06:44,000
And we place it here.

133
00:06:45,000 --> 00:06:48,000
It says true, but it is not the ledge.

134
00:06:48,000 --> 00:06:49,000
It is just a wall.

135
00:06:49,000 --> 00:06:52,000
So we have a way to control that.

136
00:06:52,000 --> 00:06:53,000
How are we going to do that?

137
00:06:53,000 --> 00:06:59,000
We're going to disable Let's check if there is a wall in front of us.

138
00:07:00,000 --> 00:07:06,000
And if there is no wall in front or above and only below, then we're going to know it is a ledge.

139
00:07:07,000 --> 00:07:07,000
How are we going to do that?

140
00:07:07,000 --> 00:07:09,000
I'm going to show you right now.

141
00:07:09,000 --> 00:07:13,000
And let's select, let's check, choose what is ground, because I didn't do it before.

142
00:07:13,000 --> 00:07:19,000
And we're going to add component box Collider that we're going to make is trigger and we're going to

143
00:07:19,000 --> 00:07:21,000
use on trigger enter.

144
00:07:21,000 --> 00:07:24,000
If you never faced an trigger enter before, don't worry.

145
00:07:24,000 --> 00:07:27,000
Later in the course, we're going to discuss it deeply.

146
00:07:27,000 --> 00:07:29,000
I would say for now we're just going to use it.

147
00:07:29,000 --> 00:07:30,000
You just follow me.

148
00:07:30,000 --> 00:07:32,000
And it's not complicated, honestly.

149
00:07:32,000 --> 00:07:39,000
So this is a collider we have here, and we can turn this collider into a trigger.

150
00:07:39,000 --> 00:07:43,000
And when something enters the collider, we can make something happen.

151
00:07:43,000 --> 00:07:46,000
So that is basically called on trigger enter.

152
00:07:46,000 --> 00:07:48,000
Now we have this trigger, right?

153
00:07:49,000 --> 00:07:54,000
I'm going to make it like this and I'm going to go to ledge detection back again.

154
00:07:55,000 --> 00:08:00,000
Create a boolean private bool can detect.

155
00:08:01,000 --> 00:08:10,000
Now let's go over here and create a function which is called on trigger Enter to DX over here.

156
00:08:10,000 --> 00:08:20,000
Now, what we do here, we say if collision dot game object, dot layer equals equals to layer mask

157
00:08:20,000 --> 00:08:21,000
dot.

158
00:08:22,000 --> 00:08:30,000
Name to layer so we can get a layer by name and in the parentheses and quotation marks we should say

159
00:08:30,000 --> 00:08:35,000
ground and please be sure it is named same as an layer in unity.

160
00:08:35,000 --> 00:08:37,000
You can check it.

161
00:08:38,000 --> 00:08:39,000
Over here.

162
00:08:39,000 --> 00:08:42,000
If you go to layers over here, ground, right.

163
00:08:42,000 --> 00:08:44,000
So name should be saved.

164
00:08:44,000 --> 00:08:48,000
And let's go back and we do this on trigger enter.

165
00:08:48,000 --> 00:08:52,000
If layer is ground, then can detect equals to false.

166
00:08:52,000 --> 00:08:57,000
Now we're going to create another on trigger but exit on trigger exit to the.

167
00:08:58,000 --> 00:09:00,000
And we're going to copy these two lines.

168
00:09:02,000 --> 00:09:05,000
Paste it in here, but make it true.

169
00:09:06,000 --> 00:09:08,000
Then we're going to update.

170
00:09:09,000 --> 00:09:13,000
And we say if can detect, then we do this detection.

171
00:09:13,000 --> 00:09:14,000
Pretty simple.

172
00:09:14,000 --> 00:09:16,000
Now, let's try it again.

173
00:09:16,000 --> 00:09:19,000
I will take my inspector and I'll turn it into debug mode.

174
00:09:19,000 --> 00:09:22,000
So we can see, can detect boolean.

175
00:09:22,000 --> 00:09:24,000
Now, look, if I take my ground.

176
00:09:25,000 --> 00:09:27,000
And I'll make it something like this.

177
00:09:27,000 --> 00:09:29,000
Move it in front of the character.

178
00:09:31,000 --> 00:09:35,000
Now let me look the ledger check so we can see it.

179
00:09:35,000 --> 00:09:35,000
Click.

180
00:09:35,000 --> 00:09:36,000
Look over here.

181
00:09:38,000 --> 00:09:39,000
Now check this out.

182
00:09:39,000 --> 00:09:44,000
If I enter, the trigger from this side can detect turns to false.

183
00:09:45,000 --> 00:09:47,000
You watch this one, right?

184
00:09:47,000 --> 00:09:50,000
If I move it out, can detect equals to true.

185
00:09:51,000 --> 00:09:56,000
If I make it long and place it like this again, can detect false.

186
00:09:57,000 --> 00:10:01,000
But if it is a wall and we say.

187
00:10:02,000 --> 00:10:04,000
Move it from below.

188
00:10:05,000 --> 00:10:08,000
It does not switch off can detect boolean.

189
00:10:08,000 --> 00:10:12,000
And actually you can see here that our alleged detection became true.

190
00:10:12,000 --> 00:10:14,000
It is happening because of the collider.

191
00:10:14,000 --> 00:10:20,000
We said before, if I go back to normal mode and click edit on my collider, you see how it is set.

192
00:10:20,000 --> 00:10:27,000
So if we enter this trigger from the right top or left side and actually we do need left side, only

193
00:10:27,000 --> 00:10:28,000
right side.

194
00:10:28,000 --> 00:10:28,000
Yeah.

195
00:10:28,000 --> 00:10:32,000
Anyway, we said can detect to false and we are no longer able to detect.

196
00:10:32,000 --> 00:10:36,000
But if we move in platform from the bottom, where is it.

197
00:10:36,000 --> 00:10:36,000
Yeah.

198
00:10:36,000 --> 00:10:43,000
You can see that this ground platform entered the alleged detection before it entered the trigger.

199
00:10:43,000 --> 00:10:45,000
So it is able to detect.

200
00:10:45,000 --> 00:10:46,000
I hope that makes sense.

201
00:10:46,000 --> 00:10:51,000
If it's still a bit confusing to you, please don't worry with the time, it will be super simple to

202
00:10:51,000 --> 00:10:51,000
understand.

203
00:10:51,000 --> 00:10:52,000
All right.

204
00:10:52,000 --> 00:10:55,000
So as of now, let's just make sure our detection is working.

205
00:10:55,000 --> 00:10:57,000
I'm going to clear it.

206
00:10:57,000 --> 00:11:06,000
And if I place my role like this false if I go from the top false.

207
00:11:06,000 --> 00:11:08,000
But if I go from the bottom.

208
00:11:09,000 --> 00:11:09,000
True.

209
00:11:10,000 --> 00:11:11,000
The true goes right.

210
00:11:11,000 --> 00:11:17,000
If I place my role like this and I move my character, let's say, to the wall and then he is jumping,

211
00:11:18,000 --> 00:11:19,000
it is false.

212
00:11:19,000 --> 00:11:21,000
False, false, false, false, false, false.

213
00:11:21,000 --> 00:11:22,000
And then boom, true.

214
00:11:22,000 --> 00:11:23,000
Let's detect it.

215
00:11:23,000 --> 00:11:24,000
Perfect.

216
00:11:24,000 --> 00:11:29,000
Next we go into freeze the player at the position of let's check.

217
00:11:30,000 --> 00:11:31,000
Let's delete this debug.

218
00:11:33,000 --> 00:11:37,000
Go to the top and we're going to create another header.

219
00:11:37,000 --> 00:11:39,000
Header Ledge info.

220
00:11:40,000 --> 00:11:45,000
Now foliage in four info we need offset and I'm going to explain why in a minute.

221
00:11:45,000 --> 00:11:47,000
For now, just repeat after me.

222
00:11:48,000 --> 00:11:51,000
Try what vector to offset.

223
00:11:54,000 --> 00:12:00,000
One and then serialize field private vector to offset to OC.

224
00:12:01,000 --> 00:12:02,000
Now we need.

225
00:12:03,000 --> 00:12:10,000
Another vector too, and it can be just private without serialize field, private vector to climb,

226
00:12:10,000 --> 00:12:19,000
begun position and then private vector to climb over position.

227
00:12:19,000 --> 00:12:20,000
Cool.

228
00:12:20,000 --> 00:12:22,000
Now we need couple of booleans.

229
00:12:22,000 --> 00:12:28,000
First one will be private bool can grab, which means can grab the ledge.

230
00:12:28,000 --> 00:12:34,000
Maybe we should write it can grab ledge and then another boolean private bool can climb.

231
00:12:35,000 --> 00:12:37,000
All right, we have all set.

232
00:12:37,000 --> 00:12:43,000
Now let's go and create a function over here that's going to be named as private void.

233
00:12:43,000 --> 00:12:45,000
Check for ledge.

234
00:12:47,000 --> 00:12:47,000
Inside.

235
00:12:47,000 --> 00:12:52,000
What we're going to do is to check if ledge detect it.

236
00:12:52,000 --> 00:12:58,000
And you remember we said this pledge detected with alleged detection from the child over here.

237
00:12:58,000 --> 00:13:02,000
So now if ledge detect it and.

238
00:13:02,000 --> 00:13:04,000
Can grab lunch.

239
00:13:05,000 --> 00:13:08,000
Then we're going to set can grab lunch to force.

240
00:13:08,000 --> 00:13:10,000
So it happens only once.

241
00:13:10,000 --> 00:13:10,000
False.

242
00:13:10,000 --> 00:13:15,000
Then we need to assign position before climb and after climb.

243
00:13:15,000 --> 00:13:16,000
Maybe.

244
00:13:16,000 --> 00:13:20,000
Let's step aside and I'll explain to you why we need position before and after.

245
00:13:20,000 --> 00:13:22,000
All right, Just for a second.

246
00:13:22,000 --> 00:13:23,000
So check this out.

247
00:13:23,000 --> 00:13:26,000
We have Let me find it platform.

248
00:13:28,000 --> 00:13:33,000
So at the moment we detect in the ledge we're going to freeze position of the player at the place where

249
00:13:33,000 --> 00:13:35,000
ledge was detected right here.

250
00:13:36,000 --> 00:13:42,000
Then we're going to play an animation of a ledge climb from the first frame.

251
00:13:44,000 --> 00:13:45,000
Just like this.

252
00:13:46,000 --> 00:13:53,000
And at the first frame of this animation, we're going to assign position that we are about to create

253
00:13:53,000 --> 00:13:55,000
position before a client.

254
00:13:55,000 --> 00:13:57,000
And it should be somewhere here.

255
00:13:57,000 --> 00:13:59,000
So it looks properly, right?

256
00:13:59,000 --> 00:14:01,000
So this is our position before client.

257
00:14:02,000 --> 00:14:03,000
Then we're going to play animation.

258
00:14:04,000 --> 00:14:10,000
And when animation is over, we're going to move position of the character to position after client

259
00:14:10,000 --> 00:14:14,000
and we're going to play idle animation and it's going to be just perfect.

260
00:14:14,000 --> 00:14:15,000
So let's go back first.

261
00:14:15,000 --> 00:14:17,000
Let's get position of the ledge check.

262
00:14:17,000 --> 00:14:28,000
So we're going to do vector to ledge position equals to get component in children ledge detection transform

263
00:14:28,000 --> 00:14:29,000
dot position.

264
00:14:30,000 --> 00:14:40,000
Now we're going to do this climb began position equals to ledge position plus of set one, then climb

265
00:14:40,000 --> 00:14:41,000
over.

266
00:14:41,000 --> 00:14:46,000
Position equals to ledge position plus offset.

267
00:14:46,000 --> 00:14:52,000
Now we're going to set can claim to true and we're going to create another if statement that says if

268
00:14:52,000 --> 00:14:59,000
can claim true, then transform position equals to climb begun position.

269
00:14:59,000 --> 00:15:00,000
So what are we doing here?

270
00:15:01,000 --> 00:15:06,000
Basically, if let's detect it and we can grab the ledge, then we grab in the ledge.

271
00:15:06,000 --> 00:15:13,000
We're saying we can no longer grab the ledge, we get in position of the ledge itself.

272
00:15:13,000 --> 00:15:19,000
Then we set in position before climb began and we set in position after climb is over with the help

273
00:15:19,000 --> 00:15:21,000
of the ledge position and the offset.

274
00:15:21,000 --> 00:15:23,000
Then we're saying that we have position.

275
00:15:23,000 --> 00:15:26,000
We can no longer grab the edge, but we can climb.

276
00:15:26,000 --> 00:15:28,000
So we set it to true.

277
00:15:28,000 --> 00:15:35,000
And then if we can climb, if this boolean is true, then we hold in position of the player at the climb

278
00:15:35,000 --> 00:15:36,000
began position.

279
00:15:36,000 --> 00:15:42,000
Now I only want to check if can grab ledge is true because we never set it to true at first place.

280
00:15:43,000 --> 00:15:44,000
Okay, Over here.

281
00:15:44,000 --> 00:15:46,000
We need to make it true by default.

282
00:15:46,000 --> 00:15:49,000
If you don't write anything here, then default value will be false.

283
00:15:49,000 --> 00:15:52,000
If you want to make it true by default, we need to do it.

284
00:15:52,000 --> 00:15:53,000
Okay, cool.

285
00:15:53,000 --> 00:15:56,000
Now let's go back and see if this working.

286
00:15:56,000 --> 00:15:57,000
And I'm pretty sure it is.

287
00:15:58,000 --> 00:16:02,000
I'm going to select my level part and just add another platform.

288
00:16:04,000 --> 00:16:05,000
Okay.

289
00:16:05,000 --> 00:16:06,000
Let's go to play mode.

290
00:16:06,000 --> 00:16:11,000
Now, if I'll jump, we can see I stuck in the position of the ledge.

291
00:16:11,000 --> 00:16:12,000
And this is perfect.

292
00:16:12,000 --> 00:16:14,000
This is exactly what we need.

293
00:16:14,000 --> 00:16:16,000
Now, let's do this.

294
00:16:16,000 --> 00:16:18,000
Let's go to graphics.

295
00:16:18,000 --> 00:16:19,000
Fine player.

296
00:16:20,000 --> 00:16:21,000
Climb.

297
00:16:21,000 --> 00:16:23,000
We're going to take first pride and drag it here.

298
00:16:23,000 --> 00:16:30,000
Then we're going to go to Idol, Take first pride, drag it here and select both of them.

299
00:16:30,000 --> 00:16:33,000
We're going to change certain layer so we can see it.

300
00:16:33,000 --> 00:16:36,000
And now we need to define offset of the player how we can do it.

301
00:16:36,000 --> 00:16:39,000
We can just take this two sprites, make them child of the player.

302
00:16:39,000 --> 00:16:44,000
Then let's take the first one, drag it so we can see it.

303
00:16:44,000 --> 00:16:45,000
And I cannot actually see.

304
00:16:45,000 --> 00:16:49,000
So maybe I will switch off sprite of the player.

305
00:16:51,000 --> 00:16:52,000
Okay.

306
00:16:52,000 --> 00:16:56,000
He should be placed somewhere here.

307
00:16:56,000 --> 00:16:58,000
This looks okay.

308
00:16:58,000 --> 00:17:06,000
Now let's go to Notepad and we're going to type before climb X is minus point five.

309
00:17:06,000 --> 00:17:15,000
We can see that we're here in the corner, minus point five, F and Y is -1.2.

310
00:17:15,000 --> 00:17:17,000
So this is how he should be.

311
00:17:17,000 --> 00:17:18,000
Before we climb.

312
00:17:18,000 --> 00:17:22,000
Then let's take a second Sprite and define how he should be after climb.

313
00:17:23,000 --> 00:17:27,000
We're going to place him somewhere here in a proper position.

314
00:17:29,000 --> 00:17:30,000
Then we can see position here.

315
00:17:30,000 --> 00:17:33,000
Point 57 and 1.3.

316
00:17:33,000 --> 00:17:34,000
Let's go to Notepad.

317
00:17:34,000 --> 00:17:36,000
After climb.

318
00:17:38,000 --> 00:17:46,000
X 1.7 fy1 .33 f oc Cool.

319
00:17:50,000 --> 00:17:52,000
Now let's uncheck play mode.

320
00:17:52,000 --> 00:17:57,000
Go to player and write these two offsets minus.

321
00:17:59,000 --> 00:18:00,000
Minus five.

322
00:18:02,000 --> 00:18:03,000
Here.

323
00:18:03,000 --> 00:18:06,000
-1.23.

324
00:18:08,000 --> 00:18:13,000
Here, point 57 and here, 1.33.

325
00:18:13,000 --> 00:18:18,000
And again, your values can be different from mine.

326
00:18:18,000 --> 00:18:18,000
All right.

327
00:18:18,000 --> 00:18:22,000
If you place the alleged check, just not where I did.

328
00:18:22,000 --> 00:18:26,000
If your position is not the same, then your offset might be a bit different.

329
00:18:26,000 --> 00:18:29,000
That's why we using this picture to define offset.

330
00:18:29,000 --> 00:18:30,000
All right.

331
00:18:30,000 --> 00:18:34,000
That's why we place it like that so we can see where he is going to be.

332
00:18:34,000 --> 00:18:36,000
So you do not look at my numbers?

333
00:18:36,000 --> 00:18:39,000
Of course you can check my numbers, but you do not check my numbers.

334
00:18:39,000 --> 00:18:42,000
You go to play mode just like I did.

335
00:18:42,000 --> 00:18:47,000
And you grab the ledge first, just like I did.

336
00:18:48,000 --> 00:18:48,000
Sorry.

337
00:18:48,000 --> 00:18:50,000
Already doing it with the offset?

338
00:18:50,000 --> 00:18:51,000
Yeah.

339
00:18:51,000 --> 00:18:52,000
No, Let me put zero zero here.

340
00:18:58,000 --> 00:19:00,000
So you grab the ledge just like I did.

341
00:19:00,000 --> 00:19:07,000
Then you go to graphics ledge, climb, find this sprite, make it certain layer player and place it

342
00:19:07,000 --> 00:19:09,000
somewhere so you can see it.

343
00:19:11,000 --> 00:19:12,000
Yeah.

344
00:19:12,000 --> 00:19:18,000
Make sure it's a child of the player so we know the offset actually plays it how you want it to be.

345
00:19:18,000 --> 00:19:19,000
Just like this.

346
00:19:20,000 --> 00:19:21,000
Then check the numbers.

347
00:19:21,000 --> 00:19:23,000
You see now, these numbers are different.

348
00:19:23,000 --> 00:19:29,000
Not the same I wrote before, so you need to check it by yourself and then you write it here.

349
00:19:30,000 --> 00:19:34,000
OC Okay, so what is it, minus four or five?

350
00:19:34,000 --> 00:19:35,000
Eight?

351
00:19:35,000 --> 00:19:35,000
Yeah.

352
00:19:37,000 --> 00:19:41,000
It's the Y and this is minus four, five, eight.

353
00:19:42,000 --> 00:19:42,000
Okay.

354
00:19:43,000 --> 00:19:45,000
Now, I don't need this notepad anymore.

355
00:19:46,000 --> 00:19:47,000
Close it.

356
00:19:47,000 --> 00:19:51,000
Let's go back to code and set animator.

357
00:19:52,000 --> 00:19:55,000
We need to find animation controllers.

358
00:19:56,000 --> 00:19:59,000
And here we said Anim, said bull.

359
00:20:01,000 --> 00:20:02,000
Can claim.

360
00:20:03,000 --> 00:20:05,000
Two can claim.

361
00:20:10,000 --> 00:20:10,000
Okay.

362
00:20:10,000 --> 00:20:11,000
Save it.

363
00:20:11,000 --> 00:20:12,000
Let's go.

364
00:20:25,000 --> 00:20:27,000
We're about to be done, actually.

365
00:20:29,000 --> 00:20:30,000
Och, this is good.

366
00:20:31,000 --> 00:20:35,000
What happens here is transition between two animations over and over again.

367
00:20:35,000 --> 00:20:37,000
If you go to animator, you can see it.

368
00:20:37,000 --> 00:20:41,000
So to stop this, we just need to add one condition.

369
00:20:41,000 --> 00:20:47,000
Let's go to this condition and add plus can climb should be false.

370
00:20:47,000 --> 00:20:52,000
If you want the transfer to jump fall from any state can climb should be false.

371
00:20:52,000 --> 00:20:54,000
Now let's go to play mode.

372
00:20:59,000 --> 00:21:00,000
Cool, right?

373
00:21:00,000 --> 00:21:02,000
Mine looks nice.

374
00:21:02,000 --> 00:21:04,000
I hope yours as well.

375
00:21:04,000 --> 00:21:05,000
Good.

376
00:21:05,000 --> 00:21:10,000
Now, what we do next is we need to stop this animation, and we need to actually change position of

377
00:21:10,000 --> 00:21:11,000
the player.

378
00:21:11,000 --> 00:21:12,000
How to do that?

379
00:21:12,000 --> 00:21:12,000
Very simple.

380
00:21:12,000 --> 00:21:14,000
Let's go back to code.

381
00:21:17,000 --> 00:21:21,000
Maybe right above the Czech village, we're going to create private void.

382
00:21:21,000 --> 00:21:22,000
I know.

383
00:21:22,000 --> 00:21:23,000
You know what?

384
00:21:23,000 --> 00:21:23,000
Let's do it below.

385
00:21:23,000 --> 00:21:25,000
I want to do it below.

386
00:21:25,000 --> 00:21:26,000
Just here.

387
00:21:27,000 --> 00:21:29,000
Private void.

388
00:21:30,000 --> 00:21:31,000
Let.

389
00:21:31,000 --> 00:21:31,000
And.

390
00:21:34,000 --> 00:21:34,000
Yeah.

391
00:21:34,000 --> 00:21:34,000
Yeah.

392
00:21:34,000 --> 00:21:36,000
Let's climb over.

393
00:21:36,000 --> 00:21:38,000
And inside we're going to do.

394
00:21:40,000 --> 00:21:50,000
Can claim false because claim is over, then we're going to do transform position equals to claim over

395
00:21:50,000 --> 00:21:53,000
position and.

396
00:21:54,000 --> 00:21:56,000
Can grub ledge equals true.

397
00:21:56,000 --> 00:21:58,000
Let's go back to Unity now.

398
00:21:59,000 --> 00:22:00,000
Begin to select player.

399
00:22:00,000 --> 00:22:03,000
Find animation of the ledge climb.

400
00:22:05,000 --> 00:22:09,000
Go to the last frame or maybe even one after.

401
00:22:09,000 --> 00:22:12,000
Click add event and find ledge.

402
00:22:12,000 --> 00:22:14,000
Climb over.

403
00:22:22,000 --> 00:22:24,000
This might cause a little bug.

404
00:22:24,000 --> 00:22:26,000
And I'm going to show you how to fix it, if it will.

405
00:22:28,000 --> 00:22:28,000
Yeah.

406
00:22:28,000 --> 00:22:30,000
So now it works perfectly.

407
00:22:30,000 --> 00:22:33,000
And now there was a bug you see, in that it was triggered twice.

408
00:22:33,000 --> 00:22:34,000
So what happens here?

409
00:22:34,000 --> 00:22:41,000
We set in our can grab latch to true at the moment when player is still is attached to the ledge and

410
00:22:41,000 --> 00:22:44,000
he detected ledge again and he's doing all the process again.

411
00:22:44,000 --> 00:22:47,000
So what we need here is to make a short delay.

412
00:22:47,000 --> 00:22:53,000
How we can do that We can create a function private void, allow ledge grab.

413
00:22:53,000 --> 00:22:58,000
It's going to return only one line of code so we don't necessarily have to type curly brackets.

414
00:22:58,000 --> 00:23:03,000
We can just put return sign, which is combination of equals and bigger.

415
00:23:03,000 --> 00:23:09,000
So this means return and it will say return can grab ledge equals true.

416
00:23:10,000 --> 00:23:15,000
Now we're going to go back to a ledge, climb over and instead of this line of code, we're going to

417
00:23:15,000 --> 00:23:15,000
type.

418
00:23:17,000 --> 00:23:20,000
Invoke and invoke means you can call function with the delay.

419
00:23:20,000 --> 00:23:24,000
Just how it says here invokes method name in time seconds.

420
00:23:24,000 --> 00:23:28,000
So in the parentheses we're going to put quotation marks.

421
00:23:28,000 --> 00:23:31,000
We need a name of the function and it should be exact name.

422
00:23:31,000 --> 00:23:37,000
So let's copy it here, paste it in here, and then put comma point one F Now it should be fine.

423
00:23:37,000 --> 00:23:38,000
Let's go back.

424
00:23:42,000 --> 00:23:42,000
And.

425
00:23:46,000 --> 00:23:47,000
Works perfectly.

426
00:23:49,000 --> 00:23:52,000
Now there might be some issue just like what I showed you.

427
00:23:52,000 --> 00:23:55,000
But I know this because I faced this before.

428
00:23:55,000 --> 00:24:01,000
Look, if I'm jumping from here, he's not detecting ledge, but he's supposed to right from here.

429
00:24:01,000 --> 00:24:06,000
He does detect in a ledge, but from above he does not.

430
00:24:06,000 --> 00:24:07,000
So what happens here?

431
00:24:07,000 --> 00:24:10,000
Sometimes there is no enough time to make detection.

432
00:24:10,000 --> 00:24:11,000
Right.

433
00:24:12,000 --> 00:24:13,000
Let me show it to you.

434
00:24:17,000 --> 00:24:18,000
All right, So.

435
00:24:22,000 --> 00:24:28,000
So he's there and he's supposed to detect the ledge but rigid by they move so fast that there is no

436
00:24:28,000 --> 00:24:29,000
time to detect the ledge.

437
00:24:29,000 --> 00:24:34,000
What we can do here is we can take our ledge detection.

438
00:24:34,000 --> 00:24:37,000
And rigid body to it rooted by the two D.

439
00:24:38,000 --> 00:24:42,000
Then I'm going to open this rigid body and change body type to kinematic.

440
00:24:43,000 --> 00:24:45,000
Collision detection should be continuous.

441
00:24:46,000 --> 00:24:47,000
We can close this now.

442
00:24:48,000 --> 00:24:52,000
So this what will help us to detect collision even if we move in fast?

443
00:24:53,000 --> 00:24:53,000
Yeah.

444
00:24:53,000 --> 00:24:54,000
Continuous detection.

445
00:24:55,000 --> 00:24:57,000
Then we can cover it.

446
00:24:57,000 --> 00:25:03,000
And just in case, let's increase the box Collider of our trigger to the right side to something like

447
00:25:03,000 --> 00:25:04,000
this.

448
00:25:04,000 --> 00:25:06,000
You don't have to do precise copy.

449
00:25:06,000 --> 00:25:08,000
Just make it a bit bigger and longer.

450
00:25:08,000 --> 00:25:11,000
All right, Now we can check it again.

451
00:25:11,000 --> 00:25:12,000
Let me try that.

452
00:25:12,000 --> 00:25:19,000
Right now, it's okay detecting from any spot, but we can see that sometimes offset is really off and

453
00:25:19,000 --> 00:25:22,000
there is a bit of space between the player and the platform.

454
00:25:22,000 --> 00:25:27,000
We can fix that just by finding our check and.

455
00:25:28,000 --> 00:25:29,000
Decrease in the radius.

456
00:25:29,000 --> 00:25:33,000
So maybe, I don't know, like 1.5 to make it small.

457
00:25:33,000 --> 00:25:36,000
And now we need to adjust offset just by bit.

458
00:25:36,000 --> 00:25:37,000
I don't know.

459
00:25:37,000 --> 00:25:38,000
I'll try here.

460
00:25:38,000 --> 00:25:39,000
25.

461
00:25:39,000 --> 00:25:40,000
Not sure.

462
00:25:42,000 --> 00:25:43,000
Let me change to focused.

463
00:25:46,000 --> 00:25:46,000
Yeah.

464
00:25:46,000 --> 00:25:47,000
It looks like it's okay.

465
00:25:49,000 --> 00:25:50,000
Yeah, it's fine.

466
00:25:52,000 --> 00:25:55,000
If you still have a bit of offset, try to just adjust these values.

467
00:25:56,000 --> 00:25:59,000
And remember, first offset is for position before the climb.

468
00:25:59,000 --> 00:26:03,000
Second, offset for position after climb.

469
00:26:03,000 --> 00:26:06,000
Let's go and put some comments there so you won't forget it.

470
00:26:06,000 --> 00:26:08,000
Offset for position.

471
00:26:08,000 --> 00:26:10,000
Be for a climb.

472
00:26:10,000 --> 00:26:12,000
I'm going to copy this.

473
00:26:13,000 --> 00:26:14,000
Paste it in here.

474
00:26:14,000 --> 00:26:16,000
Offset for position.

475
00:26:18,000 --> 00:26:19,000
After a climb.

476
00:26:21,000 --> 00:26:22,000
Thank you for attention.

477
00:26:22,000 --> 00:26:24,000
I know it was a long video.

478
00:26:24,000 --> 00:26:26,000
I know it might be difficult.

479
00:26:26,000 --> 00:26:30,000
I remember myself when I did something like this, and it felt complicated.

480
00:26:30,000 --> 00:26:34,000
But I'm telling you, in no time you'll be creating your own video games.

481
00:26:34,000 --> 00:26:37,000
I'll see in the next video by.

