﻿1
00:00:00,600 --> 00:00:01,633
All right.

2
00:00:01,633 --> 00:00:04,800
Now we're going to actually add some code

3
00:00:05,033 --> 00:00:08,033
to our sword attack.

4
00:00:08,066 --> 00:00:08,700
Okay.

5
00:00:08,700 --> 00:00:11,300
So currently it's pretty barebones.

6
00:00:11,300 --> 00:00:15,366
It just gets thrown into the wild
without any code inside it.

7
00:00:15,600 --> 00:00:17,600
But now let's give it some code.

8
00:00:17,600 --> 00:00:21,800
So for starters,
we are going to create an AI component

9
00:00:21,800 --> 00:00:27,433
when hit with the paper Sprite right now.

10
00:00:27,900 --> 00:00:29,800
First things first.

11
00:00:29,800 --> 00:00:32,100
The hit we want to record

12
00:00:32,100 --> 00:00:37,133
is cost to Melee Enemy.

13
00:00:37,166 --> 00:00:38,366
Okay.

14
00:00:38,366 --> 00:00:42,466
So this is going to happen
when it hits the melee enemy.

15
00:00:42,866 --> 00:00:45,266
That's very, very important.

16
00:00:45,266 --> 00:00:49,400
And when it comes to other actor, it's
basically the melee enemy.

17
00:00:49,400 --> 00:00:52,233
So the other actor is the object
that it hits.

18
00:00:52,233 --> 00:00:54,166
That's important.

19
00:00:54,166 --> 00:00:58,433
And then it's going to apply damage.

20
00:00:58,866 --> 00:00:59,933
How much damage?

21
00:00:59,933 --> 00:01:03,000
I think three hit kills for
enemies is good.

22
00:01:03,633 --> 00:01:06,133
So let's say 30 damage.

23
00:01:06,133 --> 00:01:08,100
I think 30 damage is good.

24
00:01:08,100 --> 00:01:09,766
So that's three hits.

25
00:01:09,766 --> 00:01:10,933
Technically. Four hits.

26
00:01:12,200 --> 00:01:12,800
Okay, fine.

27
00:01:12,800 --> 00:01:14,400
Let's make it.

28
00:01:14,400 --> 00:01:15,966
No, let's make it. Let's see.

29
00:01:15,966 --> 00:01:17,766
What would it take to get three hits?

30
00:01:17,766 --> 00:01:19,800
Let's say that is seven damage.

31
00:01:19,800 --> 00:01:22,800
Okay, so let's do some basic math.

32
00:01:24,733 --> 00:01:25,233
Okay.

33
00:01:25,233 --> 00:01:28,633
So if we make it so that it does

34
00:01:28,633 --> 00:01:32,100
30 damage, 30 times 390.

35
00:01:32,100 --> 00:01:32,800
Okay.

36
00:01:32,800 --> 00:01:37,233
If we make it do 37 damage times
three and perfect

37
00:01:37,866 --> 00:01:42,533
47 damage,
it is, That's enough to kill the enemy.

38
00:01:42,733 --> 00:01:44,233
That's great.

39
00:01:44,233 --> 00:01:46,533
Now, once it's done

40
00:01:46,533 --> 00:01:50,300
applying this damage,
I wanted to destroy itself.

41
00:01:50,300 --> 00:01:53,466
We can't have random sticks and swords
sticking around.

42
00:01:54,300 --> 00:01:57,300
So destroy

43
00:01:58,066 --> 00:01:59,033
actor.

44
00:01:59,033 --> 00:02:02,133
And I wanted to destroy this self.

45
00:02:04,233 --> 00:02:07,800
Okay, So immediately
it has done any damage.

46
00:02:07,800 --> 00:02:10,800
I want it to be out of there.

47
00:02:11,200 --> 00:02:13,533
Now he has the thing

48
00:02:13,533 --> 00:02:15,933
we need it to still destroy

49
00:02:15,933 --> 00:02:19,400
itself, even if it does

50
00:02:20,833 --> 00:02:21,600
nothing.

51
00:02:21,600 --> 00:02:24,000
Okay, so what?

52
00:02:24,000 --> 00:02:27,000
I guess Let me show you
what this looks like in action.

53
00:02:29,033 --> 00:02:31,966
And. Okay, so come on over here.

54
00:02:31,966 --> 00:02:35,133
Okay, We'll spawn one or snap out
looking the other way.

55
00:02:35,966 --> 00:02:37,166
Okay. Boom!

56
00:02:37,166 --> 00:02:40,166
It gets eaten up.

57
00:02:40,600 --> 00:02:42,233
Okay. Boom! It gets.

58
00:02:42,233 --> 00:02:44,133
It does damage. Okay?

59
00:02:44,133 --> 00:02:46,166
It is actually doing damage.

60
00:02:46,166 --> 00:02:48,400
It's just. It.

61
00:02:48,400 --> 00:02:51,800
It attacks.

62
00:02:51,900 --> 00:02:53,766
Okay. It's doing damage. Okay?

63
00:02:53,766 --> 00:02:56,400
The attacks are doing damage. And it's.

64
00:02:56,400 --> 00:02:59,166
yeah, the enemy has lost track of me.

65
00:02:59,166 --> 00:03:00,800
I snapped through.

66
00:03:00,800 --> 00:03:01,933
I snapped about killed.

67
00:03:01,933 --> 00:03:06,900
Okay, so right now, the sword attack
does disappear after doing damage.

68
00:03:06,900 --> 00:03:10,766
But we want it to disappear regardless.

69
00:03:11,133 --> 00:03:14,133
So we'll create an event tech,

70
00:03:14,666 --> 00:03:18,300
and we're going to create a basic delay.

71
00:03:19,300 --> 00:03:23,100
Now, this delay, here is the delay.

72
00:03:23,133 --> 00:03:27,366
In other words, it's
how long the attack exists.

73
00:03:27,766 --> 00:03:30,133
So I'm just going to set this up to 0.1.

74
00:03:31,166 --> 00:03:33,133
And once that's completed,

75
00:03:33,133 --> 00:03:36,733
destroy itself
basically from the moment it's created,

76
00:03:37,033 --> 00:03:40,033
it's only on screen for 0.1 seconds.

77
00:03:40,533 --> 00:03:42,833
Let's see how that looks in game.

78
00:03:42,833 --> 00:03:45,833
So it's okay.

79
00:03:48,566 --> 00:03:50,766
It's on for just 0.1 seconds.

80
00:03:50,766 --> 00:03:52,033
Snap. I run into this.

81
00:03:52,033 --> 00:03:55,033
Okay, So let's come over here.

82
00:03:56,233 --> 00:03:56,800
Okay.

83
00:03:56,800 --> 00:03:58,666
Something helpful.

84
00:03:58,666 --> 00:03:59,166
Okay.

85
00:03:59,166 --> 00:04:02,733
A snap.

86
00:04:03,466 --> 00:04:06,466
I'm basically being eaten alive.

87
00:04:07,300 --> 00:04:09,133
snap.

88
00:04:09,133 --> 00:04:10,900
Damn.

89
00:04:10,900 --> 00:04:13,200
But that's perfectly fine. Okay.

90
00:04:13,200 --> 00:04:17,200
So right now, our enemy saw it.

91
00:04:17,233 --> 00:04:23,433
Our little sort of idea
is able to completely demolish this.

92
00:04:23,700 --> 00:04:28,566
It can't hurt because it has no damage,
but it shows up for a brief flash.

93
00:04:28,900 --> 00:04:32,900
That's why it's basically a little spawn
for 0.1 seconds.

94
00:04:32,900 --> 00:04:34,000
Then it's gone.

95
00:04:34,000 --> 00:04:38,733
This is good because it's this one
that doesn't stay on forever with magic.

96
00:04:39,033 --> 00:04:41,066
So let that damage over time.

97
00:04:41,066 --> 00:04:45,566
Now we're going to give the melee enemy

98
00:04:46,566 --> 00:04:48,033
acceptance

99
00:04:48,033 --> 00:04:51,000
of the damage that's coming its way.

100
00:04:51,000 --> 00:04:53,700
So let's go into the melee enemy.

101
00:04:53,700 --> 00:04:55,033
Speaking of which, at some point

102
00:04:55,033 --> 00:04:58,033
I'm going to make a video of us
cleaning up this code anyway.

103
00:04:58,400 --> 00:05:01,100
We'll go up in the melee enemy

104
00:05:01,100 --> 00:05:03,666
and we'll create a simple event.

105
00:05:03,666 --> 00:05:06,633
Any damage or in other words, any damage

106
00:05:06,633 --> 00:05:09,633
that it's being told that it is receiving?

107
00:05:09,766 --> 00:05:12,233
Okay. We will get.

108
00:05:12,233 --> 00:05:15,233
And then me health.

109
00:05:16,133 --> 00:05:16,633
Okay.

110
00:05:16,633 --> 00:05:19,533
So basically get enemy help,

111
00:05:19,533 --> 00:05:22,533
get the damage
and we're going to subtract.

112
00:05:23,266 --> 00:05:24,233
Yeah. Okay.

113
00:05:24,233 --> 00:05:27,233
So enemy health is what's at the top here.

114
00:05:28,100 --> 00:05:29,933
It's what's being subtracted.

115
00:05:29,933 --> 00:05:33,000
We're going to subtract by the damage
that gets done.

116
00:05:33,433 --> 00:05:33,933
Okay.

117
00:05:33,933 --> 00:05:35,066
Very important.

118
00:05:35,066 --> 00:05:37,766
Less obstructing the damage
that gets done.

119
00:05:37,766 --> 00:05:41,400
And then we're going to set it to

120
00:05:43,033 --> 00:05:45,000
enemy health, right.

121
00:05:45,000 --> 00:05:49,266
So that whatever it takes
is going to be the new enemy health now.

122
00:05:49,266 --> 00:05:51,600
Okay.

123
00:05:51,600 --> 00:05:54,900
Whenever it comes
to this number over here,

124
00:05:55,200 --> 00:05:59,033
we are going to do a less than equal to.

125
00:05:59,100 --> 00:06:00,300
Okay.

126
00:06:00,300 --> 00:06:03,300
So it's less

127
00:06:03,833 --> 00:06:06,833
the moment it's health reaches zero,

128
00:06:07,200 --> 00:06:09,900
then we want it to branch.

129
00:06:09,900 --> 00:06:12,900
So create another branch.

130
00:06:13,133 --> 00:06:15,166
So the moment it's health reaches zero.

131
00:06:15,166 --> 00:06:17,433
You know what?

132
00:06:17,433 --> 00:06:18,766
Not this animations.

133
00:06:18,766 --> 00:06:21,766
I want it to destroy

134
00:06:22,433 --> 00:06:24,266
the actor.

135
00:06:24,266 --> 00:06:25,200
Okay.

136
00:06:25,200 --> 00:06:28,400
That's all it has to do immediately.

137
00:06:28,900 --> 00:06:31,766
The health bar of the melee enemy.

138
00:06:31,766 --> 00:06:32,933
It's zero.

139
00:06:32,933 --> 00:06:34,866
It gets destroyed.

140
00:06:34,866 --> 00:06:36,933
Now, let's go.

141
00:06:36,933 --> 00:06:37,900
Okay, it's coming.

142
00:06:37,900 --> 00:06:40,633
I'm not ready to fight.

143
00:06:40,633 --> 00:06:41,433
Snap.

144
00:06:41,433 --> 00:06:42,066
Need to jump.

145
00:06:42,066 --> 00:06:42,633
Need to jump.

146
00:06:42,633 --> 00:06:43,700
Okay.

147
00:06:43,700 --> 00:06:46,533
snap.

148
00:06:46,533 --> 00:06:48,433
Okay. I died.

149
00:06:48,433 --> 00:06:49,466
I die like a noob.

150
00:06:50,466 --> 00:06:51,966
An absolute noob.

151
00:06:51,966 --> 00:06:54,666
Let's go back
and try and rebalance this a bit.

152
00:06:54,666 --> 00:07:00,233
Okay, So for starters,
I think that that delay attack cooldown.

153
00:07:00,233 --> 00:07:02,933
Let me bring it down from 1 to 0.5.

154
00:07:02,933 --> 00:07:04,033
Okay.

155
00:07:04,033 --> 00:07:06,733
Then the sword attack its duration.

156
00:07:06,733 --> 00:07:10,200
Let me increase it from 1 to 0.5.

157
00:07:10,200 --> 00:07:10,500
Okay.

158
00:07:10,500 --> 00:07:14,400
So I'm able to always sword attack.

159
00:07:14,700 --> 00:07:18,633
This isn't like proper balance
for real game, but it's for demonstration.

160
00:07:18,933 --> 00:07:20,400
The balance.

161
00:07:20,400 --> 00:07:22,133
I leave it to you.

162
00:07:22,133 --> 00:07:23,766
So let's play again.

163
00:07:23,766 --> 00:07:26,766
Go in for another fight.

164
00:07:27,000 --> 00:07:28,800
It's not about looking backwards.

165
00:07:28,800 --> 00:07:31,800
Look back at the enemy. Snap

166
00:07:32,000 --> 00:07:34,466
or snap. Attack is incorrect.

167
00:07:34,466 --> 00:07:36,933
Okay,

168
00:07:36,933 --> 00:07:38,300
sweet.

169
00:07:38,300 --> 00:07:39,133
Okay, cool.

170
00:07:39,133 --> 00:07:42,133
It should be three, then it dies.

171
00:07:42,300 --> 00:07:44,533
What the hell?

172
00:07:44,533 --> 00:07:46,933
Where is the mistake?

173
00:07:46,933 --> 00:07:49,933
There is a mistake in our code.

174
00:07:50,600 --> 00:07:51,566
my goodness.

175
00:07:51,566 --> 00:07:55,633
If this is less than or equal to zero,
then true.

176
00:07:55,633 --> 00:07:57,766
Destroy the actor.

177
00:07:57,766 --> 00:07:59,400
The actor is the self.

178
00:08:01,833 --> 00:08:03,400
Okay, so

179
00:08:03,400 --> 00:08:07,666
what I want
to do, because this is not making sense.

180
00:08:08,266 --> 00:08:10,200
Why is the enemy not dying?

181
00:08:10,200 --> 00:08:11,966
The enemy should be dying.

182
00:08:11,966 --> 00:08:16,800
Let's quickly run through this code again
to just double check.

183
00:08:16,800 --> 00:08:18,366
This is perfect.

184
00:08:18,366 --> 00:08:20,633
This works.

185
00:08:20,633 --> 00:08:23,600
What exactly is missing

186
00:08:23,600 --> 00:08:27,800
should be easy in the sword attack.

187
00:08:28,866 --> 00:08:31,866
Double check the sword attack again.

188
00:08:32,033 --> 00:08:36,400
So currently the sword attack on hit
right?

189
00:08:36,700 --> 00:08:39,700
When it hits the melee enemy,

190
00:08:40,266 --> 00:08:43,933
it applies 37 damage It did.

191
00:08:43,966 --> 00:08:46,466
Then it destroys itself.

192
00:08:46,466 --> 00:08:47,866
That's cool.

193
00:08:47,866 --> 00:08:50,833
Every event tick

194
00:08:50,833 --> 00:08:53,166
there is a delay of 0.5.

195
00:08:53,166 --> 00:08:56,166
Once that's done, it destroys itself.

196
00:08:56,700 --> 00:08:58,966
Okay, that's fine.

197
00:08:58,966 --> 00:09:05,433
But I think what I want,

198
00:09:09,533 --> 00:09:11,100
I think what I want

199
00:09:11,100 --> 00:09:14,200
is a way to truly understand

200
00:09:14,200 --> 00:09:17,666
when the base damage is doing this
proper damage.

201
00:09:17,666 --> 00:09:19,733
Let's look at the player. Okay?

202
00:09:19,733 --> 00:09:21,600
The player is entirely doing its job.

203
00:09:21,600 --> 00:09:23,400
There's nothing wrong there.

204
00:09:23,400 --> 00:09:25,233
So let's go into the melee enemy.

205
00:09:26,266 --> 00:09:28,100
Let's see

206
00:09:28,100 --> 00:09:31,100
when any damage,

207
00:09:31,400 --> 00:09:33,600
let's do a simple print

208
00:09:33,600 --> 00:09:37,000
to do some debugging and we'll see

209
00:09:39,433 --> 00:09:43,333
that enemy hit.

210
00:09:43,733 --> 00:09:47,866
So that just shows that at least the on
any damage is walking.

211
00:09:48,100 --> 00:09:51,100
Okay, so enemy is hit.

212
00:09:52,166 --> 00:09:53,600
Is hit.

213
00:09:53,600 --> 00:09:54,700
Okay, perfect.

214
00:09:54,700 --> 00:09:57,700
Okay, let's have another look.

215
00:09:57,800 --> 00:09:59,200
You come over here.

216
00:09:59,200 --> 00:10:02,200
Come on. Come to me up

217
00:10:02,266 --> 00:10:05,033
in the knee.

218
00:10:05,033 --> 00:10:05,866
okay.

219
00:10:05,866 --> 00:10:08,700
That is on cooldown.

220
00:10:08,700 --> 00:10:09,466
Hold on.

221
00:10:09,466 --> 00:10:12,466
Going to wait

222
00:10:12,466 --> 00:10:13,700
was not.

223
00:10:13,700 --> 00:10:15,400
I'm actually not hitting the enemy.

224
00:10:15,400 --> 00:10:18,400
No shit.

225
00:10:20,066 --> 00:10:20,800
Hold up.

226
00:10:20,800 --> 00:10:21,866
Wait a minute.

227
00:10:21,866 --> 00:10:23,566
It's. Come back here.

228
00:10:23,566 --> 00:10:25,633
Come back to the melee enemy.

229
00:10:25,633 --> 00:10:31,200
I'm going to stop the melee
and then me from moving on different axes.

230
00:10:31,200 --> 00:10:34,200
Okay, so let's start by constraining it.

231
00:10:35,666 --> 00:10:36,866
It's been okay.

232
00:10:36,866 --> 00:10:39,000
Just.

233
00:10:39,000 --> 00:10:39,366
I'm not.

234
00:10:39,366 --> 00:10:42,166
I don't need its rotation to be changed.

235
00:10:42,166 --> 00:10:44,133
Just its position in the Y-axis.

236
00:10:44,133 --> 00:10:46,500
Okay, let's try this again.

237
00:10:47,500 --> 00:10:50,500
So if I come over here.

238
00:10:51,833 --> 00:10:53,233
Okay.

239
00:10:53,233 --> 00:10:56,233
snap.

240
00:10:56,400 --> 00:10:59,400
Holy snap,

241
00:11:01,800 --> 00:11:04,800
Holy snap.

242
00:11:05,133 --> 00:11:08,566
We have a
we have an enemy that's moving too fast.

243
00:11:09,766 --> 00:11:12,600
We have an enemy that's moving
way too fast.

244
00:11:12,600 --> 00:11:15,200
So fast Things fast

245
00:11:15,200 --> 00:11:15,733
moving change.

246
00:11:15,733 --> 00:11:18,500
It's speed.

247
00:11:18,500 --> 00:11:21,000
Okay, Walk, speed. 400.

248
00:11:21,000 --> 00:11:23,700
Now let's bring that down to 300.

249
00:11:23,700 --> 00:11:26,333
That's getting crazy.

250
00:11:26,333 --> 00:11:27,766
Okay, first things first.

251
00:11:27,766 --> 00:11:29,700
Warp speed, 302nd.

252
00:11:29,700 --> 00:11:33,733
We know that the on event in the damage

253
00:11:33,733 --> 00:11:37,400
is not correctly applying damage.

254
00:11:37,400 --> 00:11:38,400
Right?

255
00:11:38,400 --> 00:11:41,233
So quick check

256
00:11:41,233 --> 00:11:45,900
event and the damage
it needs to say enemies hit.

257
00:11:46,400 --> 00:11:49,200
Let's remove any athletics

258
00:11:49,200 --> 00:11:53,600
whereby it's seeing enemies
attacking the enemy attack with no walks.

259
00:11:53,633 --> 00:11:56,233
We don't need that anymore.

260
00:11:56,233 --> 00:11:58,933
So we know currently

261
00:11:58,933 --> 00:12:02,300
we only have text on enemies hit.

262
00:12:02,766 --> 00:12:06,433
So let's try that again
with a slightly slower enemy.

263
00:12:06,766 --> 00:12:10,633
If this doesn't work, it's
going to be more troubleshooting.

264
00:12:10,633 --> 00:12:11,133
Let's see.

265
00:12:14,866 --> 00:12:16,300
snap,

266
00:12:16,300 --> 00:12:19,300
run, attack isn't on cooldown.

267
00:12:20,366 --> 00:12:23,300
my goodness.

268
00:12:23,300 --> 00:12:25,200
my goodness. This.

269
00:12:25,200 --> 00:12:29,133
For some reason,
this character is moving around a lot.

270
00:12:32,933 --> 00:12:33,633
Let me quickly

271
00:12:33,633 --> 00:12:36,633
find a fix and come back again.

