1
00:00:00,000 --> 00:00:04,610
Welcome back my favor the game developers.

2
00:00:04,605 --> 00:00:08,055
In this video, we are going to be fixing a couple

3
00:00:08,055 --> 00:00:11,825
of bugs or inconveniences and our bosses movement.

4
00:00:11,820 --> 00:00:14,640
So now when we run the game and there

5
00:00:14,640 --> 00:00:17,730
are a couple of small tweaks that you might not notice.

6
00:00:17,730 --> 00:00:19,250
So for example, now,

7
00:00:19,245 --> 00:00:22,145
if we go away, we don't have the double attack.

8
00:00:22,140 --> 00:00:24,930
And we also can see that our enemy

9
00:00:24,930 --> 00:00:28,260
is being flipped every single time.

10
00:00:28,260 --> 00:00:29,750
So with that out of the way,

11
00:00:29,745 --> 00:00:33,795
let's not waste any more time and let's get to flipping.

12
00:00:33,790 --> 00:00:38,510
Oh, okay, So now that we have established

13
00:00:38,510 --> 00:00:43,570
the first type of walking and a pyruvate attacking.

14
00:00:43,565 --> 00:00:45,745
Next thing we're going to do is we're going to be

15
00:00:45,740 --> 00:00:48,230
fixing the boss movement and we're going

16
00:00:48,230 --> 00:00:51,140
to be moving forward with it throughout

17
00:00:51,140 --> 00:00:55,210
the entire boss state machine, SAP.

18
00:00:55,205 --> 00:00:56,675
So let's get started.

19
00:00:56,675 --> 00:00:59,885
The first thing I want to fix this, the double attack.

20
00:00:59,885 --> 00:01:01,055
What's the double attack?

21
00:01:01,055 --> 00:01:02,675
Well, if I run the game,

22
00:01:02,675 --> 00:01:05,065
I'm going to keep it as it is right here.

23
00:01:05,060 --> 00:01:06,500
As you can see, he comes close,

24
00:01:06,500 --> 00:01:08,200
he attacks once, twice.

25
00:01:08,195 --> 00:01:09,605
If I get away,

26
00:01:09,605 --> 00:01:11,395
he's still attacks one.

27
00:01:11,390 --> 00:01:14,710
So 12, this is the double attack.

28
00:01:14,705 --> 00:01:16,735
We don't want that to happen.

29
00:01:16,730 --> 00:01:18,460
So in order to avoid it,

30
00:01:18,455 --> 00:01:20,845
I'm going to open up the Visual Studio and

31
00:01:20,840 --> 00:01:23,430
here and on the on-state exit.

32
00:01:23,425 --> 00:01:27,205
So when we exit from the boss walk,

33
00:01:27,200 --> 00:01:30,280
I'm going to go ahead and access the animator.

34
00:01:30,275 --> 00:01:33,485
And I'm going to reset the trigger.

35
00:01:33,485 --> 00:01:37,135
So in here I'm going to say again attack.

36
00:01:37,130 --> 00:01:39,400
So what this will do is,

37
00:01:39,395 --> 00:01:42,055
you can see right here when we are in a certain distance,

38
00:01:42,050 --> 00:01:43,630
we trigger the attack.

39
00:01:43,625 --> 00:01:45,505
So we go into the attack.

40
00:01:45,500 --> 00:01:48,290
But then as soon as we exit from the walking,

41
00:01:48,290 --> 00:01:50,300
we are going to reset the trigger

42
00:01:50,300 --> 00:01:52,450
so we are no longer in the attack.

43
00:01:52,445 --> 00:01:53,765
So back in here,

44
00:01:53,765 --> 00:01:55,705
we no longer attack twice.

45
00:01:55,700 --> 00:01:57,430
So now if I run the game,

46
00:01:57,425 --> 00:02:01,775
the boss enemies should only attack once we had tax.

47
00:02:01,775 --> 00:02:04,825
So tax, we go away. There we go.

48
00:02:04,820 --> 00:02:07,750
You can see that he only attacks once.

49
00:02:07,745 --> 00:02:09,265
Great, Well that fixed.

50
00:02:09,260 --> 00:02:10,990
The next thing I would like to fix

51
00:02:10,985 --> 00:02:13,625
is the attacking animation.

52
00:02:13,625 --> 00:02:15,835
So you'll notice that he doesn't do

53
00:02:15,830 --> 00:02:18,440
the full two swings up and down.

54
00:02:18,440 --> 00:02:20,240
You're not the only one up and then

55
00:02:20,240 --> 00:02:22,040
he stops. Why is that?

56
00:02:22,040 --> 00:02:24,620
Well, because it's the exit time

57
00:02:24,620 --> 00:02:26,620
right here on the transition.

58
00:02:26,615 --> 00:02:29,315
So if I click on these, Kelly,

59
00:02:29,315 --> 00:02:31,015
and you'll notice here on

60
00:02:31,010 --> 00:02:33,440
the preview when I make the game run,

61
00:02:33,440 --> 00:02:38,050
he shoots once and then he goes back to walking,

62
00:02:38,045 --> 00:02:39,685
which is not something that we want.

63
00:02:39,680 --> 00:02:42,950
So instead what I'm going to do is I'm going to set

64
00:02:42,950 --> 00:02:47,710
the exit time to play about 90 percent of the move.

65
00:02:47,705 --> 00:02:48,505
Yep.

66
00:02:48,500 --> 00:02:51,230
There we go. Maybe even more, just a little bit more.

67
00:02:51,230 --> 00:02:54,290
So maybe 97 ish of the move.

68
00:02:54,290 --> 00:02:55,820
Let's see how that looks.

69
00:02:55,820 --> 00:02:57,980
And all of this needs to be calibrated

70
00:02:57,980 --> 00:03:00,520
based on how you want your game to feel.

71
00:03:00,515 --> 00:03:01,505
So there we go.

72
00:03:01,505 --> 00:03:05,465
We attack once, twice down and down.

73
00:03:05,465 --> 00:03:08,825
There we, then again, we start walking.

74
00:03:08,825 --> 00:03:09,395
Excellent.

75
00:03:09,395 --> 00:03:13,255
One more thing that is a little bit bothering in here is

76
00:03:13,250 --> 00:03:17,270
the exit time on the walking to the attack.

77
00:03:17,270 --> 00:03:19,070
So now we have everything set up.

78
00:03:19,070 --> 00:03:20,930
So now we should see

79
00:03:20,930 --> 00:03:23,710
a bit of a smoother way. There we go.

80
00:03:23,705 --> 00:03:27,235
So we attack, we walk, we attack, we walk,

81
00:03:27,230 --> 00:03:29,210
we attack, we walk a bit and we keep

82
00:03:29,210 --> 00:03:31,430
pushing towards the player.

83
00:03:31,430 --> 00:03:34,430
But obviously there is one thing still missing and

84
00:03:34,430 --> 00:03:37,880
that is that the enemy isn't looking in our direction,

85
00:03:37,879 --> 00:03:40,569
which is something I would call

86
00:03:40,565 --> 00:03:42,335
a huge problem because of the way

87
00:03:42,335 --> 00:03:44,285
our melee attack will be set up.

88
00:03:44,285 --> 00:03:45,995
So let's fix that.

89
00:03:45,995 --> 00:03:48,715
The first thing we're gonna do is obviously we are

90
00:03:48,710 --> 00:03:52,010
going to rotate the player just like we wrote it.

91
00:03:52,010 --> 00:03:53,180
Enemies.

92
00:03:53,180 --> 00:03:55,300
But where do we do this?

93
00:03:55,295 --> 00:03:57,505
We might want to do this and the walking.

94
00:03:57,500 --> 00:03:59,750
Well, what if we are attacking?

95
00:03:59,750 --> 00:04:01,790
We also want to be looking at the player

96
00:04:01,790 --> 00:04:03,170
and shouldn't we be also

97
00:04:03,170 --> 00:04:04,810
looking at the player and shooting?

98
00:04:04,805 --> 00:04:07,195
So this seems to be something that is

99
00:04:07,190 --> 00:04:10,120
more general and not state based.

100
00:04:10,115 --> 00:04:13,195
So we are going to create a script in here that

101
00:04:13,190 --> 00:04:17,880
is called the boss controller.

102
00:04:19,360 --> 00:04:23,300
And I'm going to wait for it to compile and add

103
00:04:23,300 --> 00:04:24,980
this boss controller to

104
00:04:24,980 --> 00:04:28,100
these Kelly boss game object in here.

105
00:04:28,100 --> 00:04:30,410
And in here, I'm going to first of all

106
00:04:30,410 --> 00:04:32,920
get a reference to the player to chase.

107
00:04:32,915 --> 00:04:35,995
So a private void.

108
00:04:35,990 --> 00:04:40,070
Void, void I had transformed.

109
00:04:40,070 --> 00:04:45,380
And the layer to chase.

110
00:04:45,380 --> 00:04:48,970
There we go, save that now and start.

111
00:04:48,965 --> 00:04:51,965
I'm going to go ahead and say that the player to chase

112
00:04:51,965 --> 00:04:56,365
is equal to the final object of type.

113
00:04:56,360 --> 00:05:00,210
The player controller.

114
00:05:00,220 --> 00:05:02,840
And I'm going to go ahead

115
00:05:02,840 --> 00:05:04,880
and access the transform on that.

116
00:05:04,880 --> 00:05:08,090
So now we have the player to chase ready to go.

117
00:05:08,090 --> 00:05:11,740
Now the next thing to do is to actually start flipping.

118
00:05:11,735 --> 00:05:14,545
The boss whenever the player goes

119
00:05:14,540 --> 00:05:17,530
from one side to the next of the enemy.

120
00:05:17,525 --> 00:05:19,685
So because we've done this already,

121
00:05:19,685 --> 00:05:22,435
I'm going to issue you it as a challenge.

122
00:05:22,430 --> 00:05:24,410
And your challenge is to rotate

123
00:05:24,410 --> 00:05:26,420
the boss in the right direction.

124
00:05:26,420 --> 00:05:28,570
So first of all, check for the position

125
00:05:28,565 --> 00:05:31,085
of the boss relative to the player's position.

126
00:05:31,085 --> 00:05:32,605
Remember, we'd get that through

127
00:05:32,600 --> 00:05:34,330
the transforms based on that,

128
00:05:34,325 --> 00:05:37,495
rotate the bus transport around the y-axis.

129
00:05:37,490 --> 00:05:40,250
So you'll need to flip 180 degrees.

130
00:05:40,250 --> 00:05:43,730
So it's similar to the way we were flipping the weapons,

131
00:05:43,730 --> 00:05:45,640
not just the NMI.

132
00:05:45,635 --> 00:05:47,435
You'll need to add the other way

133
00:05:47,435 --> 00:05:49,435
around, of course, obviously.

134
00:05:49,430 --> 00:05:54,420
And then call that method before walking the enemy.

135
00:05:54,420 --> 00:05:56,250
Test it out.

136
00:05:56,245 --> 00:05:57,535
Is there a problem?

137
00:05:57,535 --> 00:05:59,625
Why is there a problem?

138
00:05:59,620 --> 00:06:00,970
So you will obviously

139
00:06:00,970 --> 00:06:04,840
encounter a problem. No worries about that.

140
00:06:04,840 --> 00:06:05,640
Do your best.

141
00:06:05,635 --> 00:06:07,905
Find the flipping way,

142
00:06:07,900 --> 00:06:10,810
and I'll see you in just a bit.

143
00:06:10,810 --> 00:06:13,120
Okay, welcome back.

144
00:06:13,120 --> 00:06:14,730
So in the update,

145
00:06:14,725 --> 00:06:18,945
I'm going to check if the transform,

146
00:06:18,940 --> 00:06:21,820
the position dot x,

147
00:06:21,820 --> 00:06:23,460
which is that the boss,

148
00:06:23,455 --> 00:06:29,455
is greater than the layer to chase that position, the RX.

149
00:06:29,455 --> 00:06:31,935
And by the way, this is based on

150
00:06:31,930 --> 00:06:34,480
how the mass is initially looking.

151
00:06:34,480 --> 00:06:36,800
So if he was looking the other way around,

152
00:06:36,795 --> 00:06:39,965
We might have wanted to check this the other way around.

153
00:06:39,965 --> 00:06:42,805
So anyways, if the position of

154
00:06:42,800 --> 00:06:44,210
the boss is greater than

155
00:06:44,210 --> 00:06:46,150
the position of the player to chase,

156
00:06:46,145 --> 00:06:48,445
obviously on the x-axis, only.

157
00:06:48,440 --> 00:06:51,470
Then what we're going to do is in here we are going

158
00:06:51,470 --> 00:06:54,830
to get the transform dot position.

159
00:06:54,829 --> 00:06:57,039
And we are going to,

160
00:06:57,035 --> 00:07:01,265
excuse me, the Transform Rotate.

161
00:07:01,265 --> 00:07:03,425
Whereas it rotate.

162
00:07:03,425 --> 00:07:07,405
And then 0 F on the x-axis and

163
00:07:07,400 --> 00:07:12,740
180 on the y-axis and 0 on the z-axis.

164
00:07:12,740 --> 00:07:16,090
And why is that? If we go back into our game,

165
00:07:16,085 --> 00:07:19,415
and if we get these Kelly boss,

166
00:07:19,415 --> 00:07:22,565
if we do a rotation right here, there we go,

167
00:07:22,565 --> 00:07:25,705
you can see that he rotates the other way around,

168
00:07:25,700 --> 00:07:28,270
which is exactly what we want.

169
00:07:28,265 --> 00:07:31,145
So we are going to also make sure that

170
00:07:31,145 --> 00:07:36,355
else if we transform that position,

171
00:07:36,350 --> 00:07:39,420
but this time it's the other way around.

172
00:07:40,330 --> 00:07:45,950
That means that the player is what happened.

173
00:07:45,950 --> 00:07:49,130
The player is the on the other way.

174
00:07:49,130 --> 00:07:51,680
Then we are going to make sure to

175
00:07:51,680 --> 00:07:55,660
flip the enemy back again.

176
00:07:55,655 --> 00:07:58,195
So there we go.

177
00:07:58,190 --> 00:07:59,900
Save that.

178
00:07:59,900 --> 00:08:02,620
So now if we go back in here,

179
00:08:02,615 --> 00:08:03,865
and what's the problem?

180
00:08:03,860 --> 00:08:07,030
So maybe we did a typo in here. Yep, there we go.

181
00:08:07,025 --> 00:08:10,055
So back in, again,

182
00:08:10,055 --> 00:08:11,815
we run the game.

183
00:08:11,810 --> 00:08:13,920
Let's see what happens.

184
00:08:13,924 --> 00:08:15,924
And there we go.

185
00:08:15,920 --> 00:08:18,410
So obviously there is a small problem.

186
00:08:18,410 --> 00:08:20,710
What the, what was the problem?

187
00:08:20,705 --> 00:08:23,515
Obviously, our boss enemy

188
00:08:23,510 --> 00:08:25,180
is having some kind of a seizure.

189
00:08:25,175 --> 00:08:26,545
And why is that happening?

190
00:08:26,540 --> 00:08:29,300
Well, because we are trying to flip.

191
00:08:29,300 --> 00:08:31,600
So notice what happens in here on the rotation,

192
00:08:31,595 --> 00:08:34,475
we are flipping and then we are flipping back.

193
00:08:34,475 --> 00:08:37,645
We are trying to flip the enemy,

194
00:08:37,640 --> 00:08:40,700
I mean the boss based on the players direction.

195
00:08:40,700 --> 00:08:44,450
But because we are calling it every single frame and

196
00:08:44,450 --> 00:08:46,280
because of the animation that makes

197
00:08:46,280 --> 00:08:48,350
us walk in a certain direction,

198
00:08:48,349 --> 00:08:51,679
we are having this constant flipping all the time.

199
00:08:51,680 --> 00:08:54,340
So what we're going to do is back in here,

200
00:08:54,335 --> 00:08:56,695
we are going to create a variable that will

201
00:08:56,690 --> 00:08:59,440
check if we have flipped or not.

202
00:08:59,435 --> 00:09:03,685
So in here, I'm going to create a public.

203
00:09:03,680 --> 00:09:05,600
And just to keep it public for now,

204
00:09:05,600 --> 00:09:08,270
obviously we will not keep up like forever.

205
00:09:08,270 --> 00:09:12,020
So if is flipped

206
00:09:12,020 --> 00:09:16,700
lipid and I'm going to set it to false at the beginning.

207
00:09:16,700 --> 00:09:21,020
So in here we're going to check if we have a flippant.

208
00:09:21,020 --> 00:09:24,890
That means is flipped is equal

209
00:09:24,890 --> 00:09:26,150
to false because this is

210
00:09:26,150 --> 00:09:29,060
the regular direction that we're looking at.

211
00:09:29,060 --> 00:09:32,390
If the player is on the left side, right here.

212
00:09:32,390 --> 00:09:34,370
So if the player is on the left side,

213
00:09:34,370 --> 00:09:35,920
we don't want to be flipped.

214
00:09:35,915 --> 00:09:40,525
And in here is flipped is equal to true.

215
00:09:40,520 --> 00:09:42,500
Sorry.

216
00:09:42,500 --> 00:09:47,260
For some reason, the tab isn't taken what I want.

217
00:09:47,255 --> 00:09:50,725
Visual Studio Community isn't keeping up with me.

218
00:09:50,720 --> 00:09:52,850
And then we are going to add

219
00:09:52,850 --> 00:09:54,970
it in here into our conditions.

220
00:09:54,965 --> 00:09:59,635
So if the player is on the left side and,

221
00:10:00,940 --> 00:10:05,470
and is flipped, so he is flipped,

222
00:10:05,465 --> 00:10:08,515
then we are going to flip him back to the other side.

223
00:10:08,510 --> 00:10:11,950
And in here, if he is not flipped,

224
00:10:11,945 --> 00:10:15,955
then we are going to flip him back.

225
00:10:15,950 --> 00:10:18,200
So I hope you understand what's happening in here.

226
00:10:18,200 --> 00:10:19,640
First of all, we have the is

227
00:10:19,640 --> 00:10:21,860
flipped at the beginning, it's false.

228
00:10:21,860 --> 00:10:25,730
So in here, this will not work only when the player is on

229
00:10:25,730 --> 00:10:28,100
the other side of the path

230
00:10:28,100 --> 00:10:30,680
and we have not flipped, then we'll flip.

231
00:10:30,680 --> 00:10:32,090
We'll set this to true,

232
00:10:32,090 --> 00:10:35,690
and this will allow us to not flip back again when we

233
00:10:35,690 --> 00:10:39,440
are obviously not needing to be flipped.

234
00:10:39,440 --> 00:10:41,540
So run the game.

235
00:10:41,540 --> 00:10:45,640
And you'll notice now that the enemy appears,

236
00:10:45,635 --> 00:10:47,285
he goes after us.

237
00:10:47,285 --> 00:10:49,795
Obviously the distance needs to be adjusted a bit.

238
00:10:49,790 --> 00:10:51,700
And then when we go to the other side,

239
00:10:51,695 --> 00:10:53,755
whereas these flipped, there we go.

240
00:10:53,750 --> 00:10:56,350
You can see that there we go.

241
00:10:56,345 --> 00:10:57,835
He is flipped.

242
00:10:57,830 --> 00:10:59,200
He is flipped.

243
00:10:59,195 --> 00:10:59,635
Okay.

244
00:10:59,630 --> 00:11:01,180
He is not flipped.

245
00:11:01,175 --> 00:11:02,695
He is flipped.

246
00:11:02,690 --> 00:11:04,210
He is not flipped.

247
00:11:04,205 --> 00:11:05,335
So there we go.

248
00:11:05,330 --> 00:11:06,470
Now we have butter,

249
00:11:06,470 --> 00:11:08,600
movement and butter and

250
00:11:08,600 --> 00:11:10,880
a mission transitions may

251
00:11:10,879 --> 00:11:13,429
be a better distance management would be good.

252
00:11:13,430 --> 00:11:14,930
So five I think is a lot,

253
00:11:14,930 --> 00:11:18,290
maybe 3.5 is a good number.

254
00:11:18,290 --> 00:11:20,210
I don't want the player or

255
00:11:20,210 --> 00:11:23,180
actually the enemy to be hitting V player.

256
00:11:23,180 --> 00:11:25,150
Maybe even three is good.

257
00:11:25,145 --> 00:11:26,155
I'll save that.

258
00:11:26,150 --> 00:11:28,600
We added a bit of transition.

259
00:11:28,595 --> 00:11:30,355
Take your time and play around with

260
00:11:30,350 --> 00:11:33,230
the transitions and make them perfect two-way,

261
00:11:33,230 --> 00:11:34,730
you would like to,

262
00:11:34,730 --> 00:11:35,990
with that out of the way, make

263
00:11:35,990 --> 00:11:37,510
sure to commit your changes.

264
00:11:37,505 --> 00:11:39,325
I hope you enjoy it and I'll see you in

265
00:11:39,320 --> 00:11:41,510
the next video where we will be setting up

266
00:11:41,510 --> 00:11:44,380
the actual mainly attack and start

267
00:11:44,375 --> 00:11:48,115
hurting our player and not just swinging MC.

268
00:11:48,110 --> 00:11:50,340
So see you there.

