Welcome back, my fellow game developers.
I know at this point you're probably saying Michael,
every single video you say this is the longest video,
but this will be the longest video.
I hope you are excited about that or not.
I don't know, but this video
will require a lot of tweaking.
I did make a couple of mistakes and
then fix them on the spot in front of you.
So you always know that I'm transparent as much as I can,
so I'm not going to waste your time anymore.
We're going to get started.
Okay, so now we have a health bar.
We have health, we have mainly attacking,
we have walking, we have state machine,
we have everything for our boss,
but we also need to add
a bit of angry and bracket or shooting.
So let's go ahead and do that.
The first thing that we need to do is we need to actually
create points from which our boss will be shooting.
And I'm going to zoom in on the boss.
And the way the shooting is going to work is we're
going to have eight points around the boss.
Four will be the regular shooting,
and eight will be for the angry shooting.
When he gets angry, he shoots more.
That's logical. Let's go ahead and do that.
Right-click in here, create an empty shooting points.
And in here I'm going to create the first one,
which is going to be 0.1.
And let's go ahead and move it up
here or right here to his right.
Duplicate this one.
And obviously this will not be very convenient.
So I'm going to call this.
So 0.1.2, I'm going to put it on its head.
0.3, move it down in here.
And 0.4, move it right here.
Now when we will be creating
our shooting or the mosses bullet,
it will move in the direction of the bullets, right?
So we will need to rotate all of these and later on,
but for now, let's just duplicate the four.
Set it in here.
Maybe around this point almost.
And then again in here, 678.
So there we go. Now we have eight points around our boss.
Now, the next thing we need to do as we need to
go ahead and create the connections in here.
So from the walking,
a transition to the shooting,
and any transition from the shooting to the walking.
And we're going to add a trigger in here,
which is going to be the shoot.
And then up here we're going to do the same.
So make transition, may transition.
Let's have no exit time.
And yeah, keep the transition duration as it has.
No worries about that.
That's in here also have no exit time,
transition duration, the hour.
So we forgot to also add a condition in here.
So the condition is they should trigger.
And here the condition as the oh, shoot trigger.
And then going back,
we I believe we don't need to have an exit time.
And in here also,
I believe we won't have an exit time,
but we will want to play
the entire animation and then go back.
Or maybe we will see,
we will see what happens as we
create the gain, what we will need.
Now, the next obvious step is to create the buses bullet.
So I'm going to right-click inside of the Boss folder.
And in here I'm going to create the boss.
Bullet. Bullets hit Enter.
Wait for the script to compile.
And let's double-click and open it up.
And what are we going to do in here
while we are going to be doing the obvious?
So the first thing,
we'll obviously be a float for the speed.
And then we are going to have a private vector
2 or vector 3 actually for the bullet direction.
Then we will have 14 to the thalamic damage.
This should be an integer.
Okay, great. Now in
the start we are going to set
the direction of the bullet and
it's going to be blood direction
equals transform dot, right?
So right means if we look in here,
the red axis on the transform, if we go up.
So maybe I did that too fast.
So the red axis of the transform and the world space.
So back in the scene.
And notice that this one,
this is the red axis.
For example, the to the bullet will fly to the right.
So what we'll need to do as we need to rotate
it like that, I believe. So.
There we go. We can see that we have
it will set it to 90 degrees.
So the third to
a 180 degrees said
the point on the bottom to maybe 90 degrees?
No, no, not 90 degrees minus 90 degrees.
And we have this point right here. What should we set it?
Let's see.
So if you're not good path, this is perfect.
There we go. So 45, I believe.
Yeah, 45 is good for the six.
That should be minus 45. There we go.
Let's change it.
But so you can play around,
you can do whatever you want,
and however you want.
If you want, you can set all the shooting positions
to be in one direction.
Maybe like that around like that.
Yeah, sure.
Why not? So there we go.
So it should be a 135.
And why is it 135?
Well, because I've added 90 degrees and then added a 45.
This is one hundred, ten hundred goes on.
Now we have a perfect angle and this would be 135.
Yep, There we go. So now we have
really good tooling points from our boss.
So we're going to save that.
We're going to make this smaller.
And now we're going to go back into
our script and see what else we
need to do in here, an update.
I'm going to go ahead and get
the transform dot position and plus
equals the bullet direction times the speed.
And obviously Time.deltaTime.
There we go.
So Time.deltaTime makes sure
that even though this is called every single frame,
we are detaching it using the Time.deltaTime.
The next thing we're going to do,
we're going to check if
we don't have the boss in our hierarchy.
So if the boss
controller dot instance to have an instance,
we don't have an instance,
so we're going to go ahead and find most object of type.
Or maybe we should create an instance.
I think it's better,
or we can get a reference to the boss,
which is also a good idea.
But you know what? Let's just
find the boss and the world.
So fine.
Object of type, boss controller.
And if he is active and game object
and is active, active in hierarchy.
So if he's not active in the hierarchy,
then we want to destroy
all the bullets that are already flying.
Destroy game objects.
So the bolus get destroyed once the boss dies,
we don't want to have the bullets keep client.
Or if you want, we can
keep the bullets flying in the world.
It depends on your preferences.
Now the next thing we want to do is we want to
handle the way the bullets will interact with the world.
And obviously we haven't created the bullets yet.
But I'm pretty certain that at this point
you already know and have all the knowledge.
So I'm going to create an entrepreneur enter to the,
and inside of this Entrepreneur Center.
I'm going to, well,
I wanted to say that I wanted
to check for the player tag,
but as we know,
we will already make sure that the bullets only
collide with a player and nothing else.
So collision dot get component.
And we're going to check for the player health handler.
And we're going to take damage or damage player.
And in this damage player we are going to bullet
damage centered the bullet damage that we haven't here,
we can double-click and make
sure that is what we are working with.
And then what should we be doing?
Well, I believe we should destroy the game object.
But the problem in here that I don't like
is that if we hit anything else,
it will not interact with it.
So the boat will keep on flying forever.
So again, we will have to check for the collision.
So if collision.com paired tag and it's the layer,
and then we are going to do this.
And whenever we only have
one line of code under the condition,
we can avoid using the two squiggly lines.
And why did I choose again to create the tag and not
just keep it as it was because the bullet flies off.
We wanted to hit a wall to get destroyed in any case,
because we don't want the bullet to always
keep flying in the world and have a lot of
bullets and the hierarchy that will just take up
space and hinder the performance of our machine.
So finally, what else should we be doing?
I believe this is everything,
and I believe this is everything.
So let's go and create our bullet.
So where is our bullets in the prefab?
We have bullets, we have an AMI bullets or no,
we don't want to replicate the enemy bullets.
Let's go into, you know, I go.
Pullets player and still rifle, shot gun.
Let's go ahead and duplicate the shotgun called the S1,
the boss bullet at Enter.
And let's see what shall we
use in here that see the sprites.
We can use one of these and maybe
use the big, huge red one.
Yeah, Sure. Why not? Let's use the big huge red one.
Let's see how that looks in the world.
So back in the Boss prefab?
Or is it prefer bullets player?
Let's move it to outside.
So in here we have the boss bullet.
Let's put it in the scene.
There we go. This is it.
What should we be DO?
Bullets, of course, it's on the bullets layer.
Let's see what else do we have?
What shall we be doing in here?
I think the bullet is just a little bit smaller.
Scale one on the x also.
And instead of having less change,
maybe the collider, how?
Because the collider not, it's perfect.
Let's see the player bullet damage.
Obviously, we will remove the component
and we're going to go ahead and add our own,
which is the boss bullet controller. There we go.
So now we have the boss bullet controller,
the damage amount, the point of attack.
Note this is a boss control or not.
I was wondering like what,
what's wrong with this boss bullet? Boss bullets.
There we go.
So now we have speed which should be animal-like five,
bullet damage will be, can save that.
And when we do create a new prefab, don't worry,
this one will be removed or we can
just apply the changes to the boss bullet.
So back in our possibility in here,
if we scroll down and choose this one actually the boss,
but you can apply all.
And now we have the bullet regularly working.
So I guess this is a good enough bullet for us.
So I'm going to delete the boss bullet.
Now we have it in our hierarchy.
We have the script, we have the collider,
we have a rigid body which is important,
which save all of that.
And let's see what else do we need to do?
Well will lead to issue you a challenge.
And your challenge is to make the boss shoot.
So first of all, create a reference to
the shooting points and the angry shooting points.
So you'll need to create two references in here.
And this is all obviously going to happen.
And the boss controller,
then you'll need to get a reference to the bosses bullet.
Obviously, you'll need to create
a method that loops through
all the points using
a foreach loop and instantiate the bullets.
Then you'll need to create
another method for the angry shooting.
And you'll need to use the events to call
the methods and the animations so that information,
pause the video right now,
all of this will need to be done and
the boss controller and go do the challenge.
Oh, okay, welcome back.
So where are we boss,
boss controller up here we are going to go ahead and
create a serialized field of the trans form.
This will be an array obviously for the shooting points.
Then we are going to create
a serialized field for the transform,
also, the angry shooting points.
And then we are going to create
a serialized field for the game object,
which is the boss bullet.
And I hope you did the challenge.
I hope it wasn't too hard at this point,
you should be pretty
well knowledgeable with everything that we're doing.
So nothing is really knew.
That's why I'm just going through the motion
and doing everything really fast, not explaining.
So I'm pretty sure you already know most
of the things that we've done in here. Let's continue on.
What else do we need to do?
Well, we need to create the method that we want.
So in here, under the angular attacking player,
I'm going to create a public void shooting player.
And in here I'm going to create a for each loop,
or a for each loop that will
loop through all the transformed point.
And shooting player.
What? I'm shooting points.
In shooting points.
And in here we are going to instantiate
the boss bullet on
the transform dot position transform rotation.
So we need to make sure that we have the same rotation
as we had with the actual shooting point
that is instantiating.
Then we'll need to create a public void.
Angry shooting.
Let me just copy this one and add angry too.
It always add the angry, angry.
And I know this video is long.
I wanted to separate these into two videos.
One for the Basel at 14, the regular shooting.
But actually, I just
thought there's no point to it creating just a postulate.
A very simple, we already done that.
So I wanted to create two videos at the same time.
So angry shooting points.
There we go. We save that.
Now any or you can add
an extra mechanic and I do recommend that you do that.
It's pretty simple.
Instead of having these shooting points
and angry shooting points,
you can just create one huge or one big,
only the angry shooting points.
And when we are regularly shooting instead of a for each,
you can create a for loop,
go through for random points
and instantiate bullets from them.
This will be maybe a cool game mechanic.
I don't know if you want to do that.
Go ahead be my guest and long.
And I didn't do that because I actually want to
have the direction b and these four,
or you can do that, doesn't matter.
This is your game at your own things to it.
So in the syllabus I'm going to scroll down.
And where do we have it?
Okay, so shooting points, open this up.
It's me.
Just lock the scale it down,
choose the first four.
And these are the regular shooting points and
then everything else is the angry shooting points.
This is the boss bullet.
And save that.
And finally, we need to go to
the animations in the shooting.
So shooting, where should we be shooting?
Let's see, and maybe in here.
So at this position,
we add an event.
Let's just unlock this.
What we do shooting player.
Then we become smaller, bigger.
Maybe at this point again,
we had an event should player.
And then we go back maybe one last time,
and here we shoot the player.
So we should play or three times. Great.
So save that.
Now, back in our anger shooting,
so angry shooting, we become bigger.
We should have more shots right here.
So angry shooting player,
become bigger, smaller, bigger.
Why don't we become bigger?
And on this point, I don't know,
but obviously we made
a small mistake in here, but no worries.
Let's make this the angular shooting player bigger,
smaller. And other event.
Angular shooting player bigger, smaller.
I think at this point it's good.
No worries about the animation.
We didn't make it perfect.
Angry shooting player.
We save all of that.
Now we have everything set up.
The last thing that we need to do is we
need to actually go into that shooting.
And how do we want to have this mechanic?
While I think the best way to do it.
As let's say the bosses walking,
walking, walking, he can't get to the player.
The player keeps running away.
And after a certain amount of time,
he just starts shooting at the player.
So we're going to do exactly that.
I'm going to open the boss walk.
And in here I'm going to create some kind
of countdown or some kind of shock counter.
And why do we need to create a shot counter?
Well, why not a mono behavior?
Well, because when you are in a state machine behavior,
you don't have dicey a co-routine.
I meant why can't we create a whole routine?
You can create a call within,
because this is not a mono behavior,
we can only create equality and side of a mono behavior.
So for that reason in here,
I'm going to create a private float shot counter
and a serialized field for the photo shoot.
I'm save that.
And then I'm going to go into the on-state update.
And in here I'm going to say Should time as minus equal,
minus equal the time dot fixed delta time.
Was the problem in here.
Also.
Minus equal, not equal minus, sorry.
And then in here I'm going to say if
the show time as less than or equal to 0,
then we are going to go ahead into
the animator trigger and copy the shoot trucker.
Copy this should trigger,
put it in here, close this down, save all of this.
I believe we need a way to go back.
So in here we need a way to go back.
So we'll add an exit time.
And we'll make sure that we play
the entire animation to the 97 percent.
So let's see how that looks in the preview.
And there we go. We can see we play, we should,
we should we issued and then we go back to walking.
Okay, I think that's good enough.
And in here we will also have an exit time at
the 97 97 percent.
I have that. I think on the on-state exit,
we will also need to reset the shoot.
So save that. And I think that's it.
I believe this is all that we need to do.
So let's see.
In The Walking in here,
what's the short time?
Maybe after two seconds of walking.
And if we go to the angry walking,
after which time, maybe after three seconds of walking.
So these are just arbitrary numbers.
I haven't thought of if this is good or not.
So I'm going to make this bigger.
And as you can see,
there is something wrong.
First of all, we have a bullet in here which is not good.
So where is it, Where is it?
Whereas the scenes, this
bullet that will help, Let's close Dui.
What's that bullet actually doing
in here? I have no clue.
Why can't I selected, hey, welcome back.
So for some reason I cannot find what the hell this is.
Let's not worry about that.
What we need to worry about is to change
the bullets layer to the enemy bullet. Save that.
And now let's see how that looks.
When the ball shoots
us are really can't find what this is.
So he walks around,
he starts shooting and it's very bad.
Okay, great.
So obviously we have something not working properly.
Hey, welcome back.
A huge mistake that I made.
Instead of using the transform that position,
I shouldn't have used the point which is right here.
And the point which is right here.
Sorry for that.
This is very bad,
doesn't, it doesn't look good.
But there we go.
Now we fixed all the problems.
This should work right now.
So back in our game,
we should see that now when the boss shoots, there we go.
123. But for some reason
the bullet that goes up isn't shooting a properly.
So what is the problem?
There we go, we even get shot.
Let's try to see what the problem is when he shoots up.
So upwards there is a problem.
And the way I only
realized how the last one worked like for example,
look, we can use frame-by-frame.
He gets bigger 0.
Notice what happened.
So let's remove the pause.
And let's see what's happening when he shoots.
You can see that the bullet comes out,
which is the boss bullets,
see, okay, so this one,
this one comes out.
And as soon as it comes out for
some reason it just disappears.
So what's the problem in here?
Let's see, Maybe it's because of the collider.
It may be.
So let's look at the point,
obviously this 0.2 and the collider.
But it shouldn't be because of
the collider because, well,
obviously the enemy bullet does not interact
with the boss or does it come?
So I've noticed that when I move the point to up,
this does not create a problem.
So my suspicion is that the boss bullet,
which is on the enemy billet,
is interacting with this Kali boss,
which is on the layer default.
So what I'm going to do is I'm going to
create a layer for the boss.
So in the layers in here,
create a boss Skelly layer.
And then on the boss,
it's the enemy bullets.
So I'm going to go into the Edit, Project Settings,
Physics 2D, scroll down and make
sure that it does not interact with the boss.
Skull. Moves, boost Skelly, boost scaly.
Let's go back to layers,
edit layers and not boost Skelly basket.
So Muschelli does not interact with
both Skelly that work.
Back in here.
Said the boss, Kelly.
Yes, Change all children.
We save that. We go back and the project settings.
And the third is x to the
and the bus schedule does not interact with Boss Kelly,
and does not interact with the player.
But we can actually move all of these honestly,
but we'll just keep them.
And now we should see that all the bullets,
all the points fire properly,
even if that point is inside of
the box collider of the player, the enemy.
So now we should this guy, as you can see,
he shoots every two minutes to seconds or whatever it is.
So we look here. We go shoot, True?
True. Go in there.
And let's try to shoot him and make him angry.
So he is at 50 percent health.
So there is a problem with the animation.
So the problem is in the boss walk in here,
it's the shot counter.
And when the shot counter
gets set to less than or equal to 0,
we then need to reset the shot counter to be
equal to the shot time to time.
Save that.
And there we go. Everything should be working properly.
Now. We then again run the game.
Hopefully this will be the last mistake that we make.
We shoot, there we go.
We finished the shooting animation.
We walk a little bit,
and then we go back to shooting.
And is it working?
No, I don't think it's working properly.
Something is wrong.
Okay. Welcome back.
So I wasn't sure what the problem was.
It turns out the shot counter was very weird.
So when we were resetting the shot counter in here,
whenever we transitioned into the shoot,
the problem was that it only counted down
when we actually were in that state.
So we only count down when we are
on state update of the boss walk.
So the better solution is to
just move the shot counter reset,
which is just setting the shot counter to shoot time.
Nothing the on-state update but on the on-state exit.
So now the shock counter gets reset
every time we actually go into another state.
So in here, when we run the game,
you'll see that now the boss walks up,
he shoots, you'll see the shot count.
And in here, there you go.
Five goes back to 0. So there we go.
Now everything is working fine.
Now we make him angry.
Let's see the shooting if it works when we're angry.
Yep, there we go. The shooting
as much more prevalent, 123.
And I think one of them is missing.
We wanted to have in the animation several shots.
This is the longest video and
the entire course, I promise you.
So angry attack.
But do we have No,
I mean, angry shooting, 1, 2, 3, 4.
We have that we should afford.
We didn't issue the fourth.
I believe that's because of the exit time.
97. Let's play let's play the entire thing.
So one, save that,
save that, run the game.
Let's see how that looks.
And I could have just done this all off screen,
but I really wanted to show
you how everything is working.
So I hope that is good.
So how many times it will be 2,
1, 2, 3, 4,
so four, even though we're walking,
I think that's good. That's not bad.
We can shoot on the last time as we are walking.
This is good mechanics,
are bosses finally finished
after 40 minutes of recording.
That's how long it takes me after the edit,
maybe it will be a little bit less.
So I'm going to commit
all of the changes that we've made.
I'm going to say finally, made the boss.
Shoot after almost 100 mistakes.
This is not something that you should write.
This is for me to remember how much
I actually made mistakes in this video.
But in any case,
I hope you enjoy it.
I hope you appreciate the transparency and
me showing you everything
that's happening behind the scenes.
If you haven't already, this
is the perfect time to leave me
a review and I'll see you in
the next video in the last section.
Maybe I don't know where we will be creating
the actual level flow
from one scene to the next now
that we have everything in place.
So I'll see you then.