Hello, guys.
In this video, I want to show you how to make an enemy.
I actually one of the students pointed out that we have this enemy eye in the promo video, but there
is no such thing in the course.
And that was indeed true because when I created course for the first time, I kind of felt like, well,
why not to add a bonus content?
And then when I did recreation of this, you know, reworking the course, I thought, well, I don't
know if people actually need it, but apparently people need this, so I'm going to make it.
And there are two options for doing this.
First of all, we could use the player script and all of this information to make an enemy.
We could use inheritance, we could override functions, we could use same values to not make a new
one with the same name.
So this would save us some time, but I'm afraid it might bring some confusion in the way of making
it, because we did not plan to do it at the beginning.
So now I would have to override some functions, some values I would have to inherit somebody.
It's not and I don't want to confuse anyone with this process.
So better.
Let's make it from zero like it's a completely new object.
Besides, maybe you want to do this for some other project in which you don't have entire player script
created.
So we're going to do it from start from zero.
Although I want to save me some time.
I don't want to make an entire everything from the beginning.
So I'm going to take a player, duplicate this and give it name of the enemy.
Can I delete the script?
All right.
But still, we have the rigid body and a capsule collider on this, and we have a legit check that we're
going to use later.
For now, I'm going to just switch it off as well as the dust and these two.
I don't need it now.
I need only well, check.
So we have the enemy.
I'm going to make it red so it is more noticeable.
Like we know this is the enemy and I'm going to switch off player so it gets out of my way.
Very nice.
We also need animator controller for this guy.
So let's go to assets animation and I can see we don't really have a folders for everything, so we
can just.
Create a folder enemy.
Let's go inside and make animator controller enemy, AC.
I'm going to drag this on the enemy here.
Go to animator.
And we actually could use a couple of animations from the player like idle and walk.
Right?
We could do this.
So let's go to player and copy this idle move.
This is basically you know what it is, right?
Just idle and move animation in a bland tree.
Nothing the big about it.
We did it in the very beginning of the course.
So I'm going to just take it.
Press control C go to the enemy's animator and paste it here.
So now we have idle move animations for the enemy.
Now let's make a script and do a bit of a set up.
I'm going to make I'm going to make it in the scripts folder.
Enemy.
Can I drag it on the enemy and let's go inside of a script.
We need a lot of things here.
We need.
And rigid body to the army.
We need the animator so private animator anim and also we don't need these two for now.
So I'm going to delete them.
All right.
We need animator.
Collider.
I'm not sure we need the collider now, so I'm not going to make it.
Let's go to start and get component of those.
So our B equals to get component of rigid body and equals to get component of animator.
We want to have update in which we're going to have an animator controllers function so animate our
controllers and I'm going to click alt enter to generate method in which I'm going to set up float of
the x.
So any set float of the x velocity to RB velocity dot x, very good.
Now let's actually move there B so we're going to make a header.
Movement details.
And here we're going to have sterilized field.
Private float more speed and we need the jump first.
So I serialize field private float jump force which we're going to use later to make a jump.
As of now, I guess this is enough.
Let's add a bit of functionality to make him move.
So it's going to be RB velocity equals new vector to move speed and for the y RB velocity dot y.
So this supposed to just make him move, right?
I'm going to make a boolean so I can control his movement, public ball can move.
And in the update I'm going to say if can move, then move.
All right, Let's go and see this.
Going to set move speed to five.
Jump first to 15.
Go to play mode.
He's just standing there can move.
He goes and he never stops.
But it is okay.
Very nice.
I like it a lot.
Now, let's make him stop if we want to.
Just in case.
So I'm going to wrap this up in the method.
I'll tender extract method.
Movement else it's going to be just RB velocity equals to new vector to zero and RB velocity on the
Y.
So if he cannot move, he's not going to move.
Very good.
And then we can use this boolean maybe later in case we need it.
Now what I want to do, you see, just now he ran off the platform, not what I want.
I want him to jump when there is no ground in front of us.
And we need to make a collision check for this.
Going to be a lot of work to do, but I'm planning to make a cheap trick.
I'm going to copy code from the player here.
Yeah.
This one I was talking about when I told you that we could just override some functions from the player,
but we're not going to do it.
Let's just copy this.
Because this would have less confusion, even though actually inheriting functions is more correct to
do.
Yeah, but if you want to learn more about inheritance, maybe check out my course about RPG game,
the one you can see it on my instructor page or on my YouTube channel.
Going to be a lot of stuff with inheritance.
A lot of things like skills.
You know, it's an RPG game with items, experience, statistic stats, so many things and we're going
to use their inheritance a lot.
So maybe check that out if you want.
Now I'm going to paste all of that.
What I just copied.
I'm going to see what I need from this later.
As of now, I'm going to keep it like this.
I only want to make another transform serialize field.
Private transform ground.
Check all of this you've seen before.
I believe in the beginning of the course.
These things are pretty simple.
Can I make another boolean?
Private bool.
And ground forward.
All right.
And.
I want to have transform for this as well.
So serialize field private transform ground forward check.
Very nice.
I like it.
Now we need collision functions.
And also I'm going to be a cheater and I'm going to go below the player and copy them.
And as I was saying, it would be better to use inheritance for this.
But as I was saying after that, I want to show you this creation of the enemy in a vacuum.
Like there is no other script, like you have an empty project.
So we're going to copy and paste code.
Yeah.
So check collision, we have this done.
And I want to add another thing here.
First of all, I want to change this transform position of the ground.
Check to ground check that we created.
Here as well.
Ground check.
And I want to make one more check here.
And ground forward equals to physics, to the cost.
Ground forward position.
Wait a second.
Ground forward.
Check that position.
Vector two down.
We can use ground check distance for this.
And what is ground?
And we need to draw this line on the gizmos.
So I'm going to do it.
I'm going to just duplicate this line of code and change ground.
Check to ground forward.
Check.
Let me copy this.
Paste this in.
And paste this in.
All right.
So we have gizmos and we have check collision.
We need to add this function to update.
Otherwise, it won't work.
Check collision.
Yeah, I like it.
Now let's go to update and make simple if statement.
If is grounded and no ground forward, then we're going to jump.
RB Velocity equals to new vector to RB velocity dot x and for the Y it's going to be jump force.
Simple, right?
Pretty simple.
Let's go back to Unity.
I'm going to add create empty forward ground check.
I'm going to place it here.
Maybe here.
I like it like it here more.
Now, ground check.
Let's assign it Ground for check and we'll check.
Or it has different name ground forward check.
Giving a second round forward.
Now let's give them a distance and so on.
So ground check distance, just like so.
Going to place ground, check at the feet of the character and go and check forward the feet and to
the right like So maybe we can decrease distance by a bit.
Something like this.
So point seven will do.
Now, what is ground?
Ground?
We're not going to use ceiling checked for now.
And this supposed to work?
I'm going to place him here, hit the play and see this can move.
Run and jump.
Nice.
I like it.
Now, let's set up animator.
Let's add that jump full animation.
Right.
We have this on the player, I believe.
I just don't want to create animations again.
We have this jump fall.
I'm going to copy it.
Going to enemy base this in.
We need to set up velocity.
Don't forget about this and let's make a boolean.
Bull is grounded.
And if I'm not wrong from any state, we make transition to jump fall.
If not is grounded is grounded false.
We go there.
Duration zero can transit to self and check and then back to idle move if is grounded so is grounded
true.
Has extra time and check duration zero.
Can I make it pretty?
And then let's set up this in the cold as well.
Let's go back to code and then emitter controllers, we're going to set up Y and set float y velocity
to RB, velocity dot y and as well.
And set bool.
Is grounded.
Too is grounded.
Nice.
Let me double check.
Want to be sure it's working and.
Go.
Yes.
Perfect.
Now, the funny part, I'm not even sure we need this, but I want to make it.
Let's check for the enemy.
Luckily we have a bunch of functionality here and.
This one needs a player because we change in player Sledge detected boolean on this script so we would
have to change this by a bit, I guess.
How could we change this?
We could use player to read boolean from this object, but that is working nice.
So I don't want to break it.
I'm just going to do here.
If player not equals to null and can detect.
So this one will work only if there is a component of a player write assigned.
That's why that's how it's going to work.
And then we're going to add another component here.
Serialize field private enemy enemy.
And just add here.
If enemy not equals to null and can detect, then we're going to duplicate this and instead of player
we're going to type here enemy.
All right, so.
Yeah.
Kind of work around.
But I think this.
This is okay.
Looks good.
Let's close this and let's go all the way above.
Find this ledge detected boolean and I'm going to make it just public without hiding.
Inspect so I can see if Ledge was detected or not.
Let's go and check this out.
Just going to click the lock it so it is logged in.
I can see it always and going to go to play mode.
Find some platform and place in front of him.
Yeah.
Platform selected.
We can see ledge detected here.
So.
True False.
True, false.
Great.
Now let's make a functionality for kitchen this ledge.
This would take some work because I don't remember how I did it.
Let me see.
Let's climb region.
Wow.
I'm so smart.
The region.
Entire region.
So I can see it.
Good.
Let's just copy this region then.
Control C, go to the enemy.
Paste this in.
We need to acknowledge in the update.
Check foliage.
And we need to set up animation.
If I'm not wrong, let's go back in the animator.
We're going to select player.
Find this ledge climb.
Check how it works and click this.
Lock it.
So we have a transition from any state if can climb through.
And we also need to make sure it can climb false when we do in fall and jump and then go back with the
exit time of one know condition.
Good.
So I'm going to just copy this player.
Let's climb.
With a transition copy, go to enemy paste.
Paste.
Here we have it.
Come fall, any state ledge climb.
Give me a second.
I'll make it pretty.
So we need a boolean can climb if I'm not wrong.
Can climb.
Honestly, I did it so long ago, I don't really remember.
Can claim true.
All right.
So going to climb true make transition to Idol.
With the exit time of one transition duration zero, we need to make sure can transit a self unchecked
and from any state to jump fall we need to make sure can climb is.
False here.
Okay, Now it shows me some error.
Let me see.
Which does not exist in the controller.
What do you mean?
It does exist.
Here it is.
Can climb.
Okay,
Now we need to go to the enemy animation.
Find ledge climb.
Make sure there is an event and there is ledge.
Climb over.
Very good.
Very, very good.
Now we need to ascend.
Boolean of can climb because otherwise it won't work in the animator controller.
We can just do any set bull can climb to can climb.
And also I want to make enemy jump when he sees the wall so it's easier to test And also.
Well it works as it's supposed to be.
Let's go to update and in the place we call in for jump we can do or we'll detect it, then you're going
to jump.
Now we need to set up offset in the unity.
So here in the unity, we need to select enemy and do a couple of things.
First of all, I would like to decrease ground check just by a bit.
So maybe point five is okay because we don't really need it so long and the longer it is, the more
he would have chance to jump off the air.
So better keep it lower and we'll check size should be there as well because now it is zero.
So maybe point five and for the Y, I don't know, 1.5 is okay.
Now we need the offset of the ledge and I'm going to copy values from the player.
If you don't know how large check works, you better go and check the video about that in the middle
of the course where we describe in details, in DB details, how do we make let's check in general entire
video.
This video is so quick and paste because all of these things, all of the aspects we did before, during
the course and this all is just summary of the code we used before.
It's supposed to be very easy.
So that's why I'm doing everything so quick without really stepping on details.
Right.
And let's set up offset.
I know it because I've said it on the player.
So it is this one and -132.
Can I go back to enemy?
-132.
Or the second offset 57 133 so point 57 133.
All right.
Now, let me take a prefab of some level part and place it in front of him somewhere here.
Okay, let's go.
Come on, boy.
You can do it.
And.
Yeah.
Nice.
Look at this guy.
Look at him.
Go.
Yeah, It looks a bit clunky, but we're going to improve it.
I like it.
I really like it.
Well, let's make him to take the coins before I forgot.
All right.
We're going to go to Coin prefab.
Where is it?
Coin.
Here we pick an icon.
If it is a player, what they want to do is to make another check.
If collision get component of enemy.
Not because to know, then we're just going to destroy, object, destroy game object.
So player won't get any coins if he did not pick up at first.
Going to save this.
Now you're going to collect the coins and.
Yeah.
Let me double check the animator, because I think it looks not as pretty as I would like it to see.
Animator of the enemy.
We have a ledge climb, jump, fall.
And it stayed good enough.
What do you think?
I think, yes.
Now let's adjust his behavior a bit so he moves more smoothly.
Not like now.
Like a clunky and funny.
First of all, we want him to be faster.
And the speed, the speed of the character should be should be adjusted to the speed of the player.
Right.
So I'm going to take my level generator.
And place only one platform that is just a straight platform.
Or is it little generator?
Place level Part six.
Can I delete this?
Go to play mode to see him run.
He's going to run forward.
All right, now let's open the enemy and make a speed controller function.
Going to be a bit different.
Private void, speed controller.
And we need reference to the player this time.
So I'm going to make a component of a player, private player, player.
We're going to go to start and say player equals to game manager, instance player.
Okay.
So now we have position of the player and inside I want to make a couple of booleans, so I'm going
to be ball player ahead, which means player going to be in front of the enemy and this will be equals
to player transform from position that X bigger than transform position that x.
There is also another one ball.
Player fire away.
Which means we have some distance between enemy and the player.
And we're going to set it to Victor, to the distance between player transfer position and transfer
position.
And if distance is bigger than, let's say, six, then it means we are already far away.
Okay.
So now we're going to make if statement if player ahead, we're going to check if player is far away.
So if player is far away, then we can set move speed to some high value.
So move speed equals to, let's say, 19.
I don't know.
This is pretty high.
Else, we're going to set more speed to 16.
So he's kind of fast, but not really fast.
And again, this is just random values.
We can adjust them if we want to.
Now, if player is not ahead, if player is behind, then we should slower the character and if he's
behind and far away, we should make him really slow.
So if player fire away, then let's set move speed to maybe like 11 and else move speed.
We can say it.
We can set something like 14.
So I suppose that average speed of the player is 15.
And according to that, I'm making these changes.
Now let's add this function to update speed controller and back in Unity, I'm going to set up a straight
platform, switch on my player and try to run.
I'm going to go to prefab, find the level pirate with a straight platform.
Make it longer like that.
I'm going to go back, find little generator, drag this part to the generator.
Wait, Let me unlock the inspector.
So, little generator.
Mellow Part six.
Now player is switched on and we can go and check this.
So now they are like, you know, kind of running next to each other.
And in a moment, we all see that my player is faster.
What is of why they are not.
I can.
I cannot get it.
They have basically the same speed or what?
Did they do something wrong?
Oh, I did not save the script.
My bad.
We should save the script.
Okay, now let's try again.
So he small speed is 11 and I'm catching up to him and.
Now I am close enough.
So speed was higher and I need some more speed to get him.
And once I'm getting really fast.
Come on.
Most of the player is 18 oh 20 and move speed of the enemy is.
13.
So I can say, Oh, I can.
So now I cut him and we can see he's getting faster.
We maybe could give him even more speed if he's really far behind.
Let's try this.
If he's if player is ahead and player is really far.
Let's give him 21 so he can be faster than the player, maybe even 22.
Just want to check this.
All right.
This looks good.
Kind of fair, I guess.
There is.
My enemy can see his speed.
Or can this little generator.
Okay.
Some of speed 1622 1622 So he can get in distance but not close enough and he's kind of behind And if
I'll face something like bump into something, it's going to be different.
Okay, this is good.
If you want to adjust it more, feel free to play with these values.
I think this is okay for now.
Now let's see his behavior on the entire scene, on the arena.
I'm going to play some level parts.
No generator going to a place like level part one load Part five.
You might have different parts.
Doesn't really matter.
We're going to see how he behaves.
Where is the enemy?
So I would say he's doing pretty fine.
Right.
This looks good.
Yeah.
Um.
What else?
Now we want him to appear, and we want him to run only for some distance.
Because if he is living for too long, I don't want him to collect all of the coins for the player.
So after he ran some distance, he could stop.
Let's go and make a couple of variables.
So first, going to be serialized field, private float distance to run, and then we just need private
float max distance.
All right.
At the start, we're going to take transform position.
Wait.
At the start, we're going to take max distance is equals to transform position X plus distance to run.
And then in the update over here, we're going to say if transform.
Position at X bigger than max distance then we're just going to do.
Can move balls and you're not going to run anymore.
Let's go and try this.
Going to set distance to run to something like 50.
And I want to see this.
Come on, boy.
To this away.
He is like flying that much when he's next to the ledge.
Look, look.
What is it?
Oh, my God, man.
What are you trying to do?
He's supposed to be able to jump only if he sees the ground.
But at the moment, I see him jumping, and it is happening because he's detecting the wall.
So what we need to do here to fix it is to go back and just type here another curly brackets then.
Take this is grounded and move it below.
So I'm going to just delete it and type here.
If is grounded, then we can apply this code and basically this is just a jump method so we can extract
it to make it more understandable.
Extract.
Method.
Jump.
So now.
Jump has its own condition and we can jump, if not ground forward or will detect detected.
Let's take this check edge and speed controller.
Let's take all of these three.
Move them above.
And here we can just try to return after we stop movement.
Good.
Let's try to run together now.
Going to give him a distance of around maybe 150 and see how it looks.
And now we only need to make him appear.
And that's it.
Is collecting my coins.
It's giving me no chance, basically.
You know, this is better.
I don't see him.
Where is he?
All right.
I want to adjust this by a bit.
I want to make him faster when he's behind.
And I want to make distance less, like two or three so we can see him.
Let's try.
Let's try 2.5 know, 2.5.
And regarding the speed, let's see if player is ahead and far away.
Let's give him more so he will catch faster.
So maybe, I don't know, 25 and if player is ahead, but not far away, let's try 17.
I don't know.
So I guess.
And if player is behind and far away, we're going to move slower.
Yeah.
This is okay.
Now, regarding his appearance, basically the enemy itself is done.
We can wrap it up and make it as a prefab.
So let's go and do this.
We can wrap it up and make it as a prefab.
I only want to make him appear in a cool way, just like in the trailer you saw.
So for this one I need to find animations and make new animation for him.
There is a cool animation of a combat ground.
This one.
So let's go to animator.
Of the enemy.
Give me a second.
And I'm going to make a new clip.
And you know what?
I'll just name it as layer because we're using layers animations.
So why not layer ground slam?
We're going to take these animations.
Put them here.
Let me see them.
Where is the enemy?
I'm going to try to set a sample rate to 15 and supposed to be like, boom.
I like it.
Boom, boom, boom.
All right.
Now we're going to go to animator and set this animation as default set as default.
Good.
So when he appears, he's going to be in this animation.
And then.
Maybe we should take this sprite and make it as a lending animation.
This would be better.
So.
These sprites we're going to delete and make create a new clip player.
Slam lending.
Hey, let's take this.
Place them here.
Separate 15.
So this whole engine looks good.
Better.
Now let's go to animator, make a grand slam by default.
Then we're going to make transition to landing.
If is grounded.
Is grounded.
Sorry.
Condition is grounded.
True.
Exit time and check Duration zero.
And then we make transition to idle move with the exit time of one transition Duration zero.
Very well.
And maybe we should make an event that will allow player to move once he finished the slam.
So let's click add event here and go make a bit of a functionality to the enemy.
First of all.
Let's make this function that we're going to use later.
Private void any nation trigger.
It's going to.
And is going to return.
Can move through.
Okay, we have the event and now let's go to start and give him a bit of a velocity at the start.
So he flies up.
Just going to be RB velocity equals to new vector to RB velocity dot.
No.
Well, actually, let's give it a bit of velocity index as well.
RB Velocity.
New vector to.
Five on the X and maybe 12 on the Y.
All right.
There's going to be cool, I'm telling you.
So that's what we need and we're going to set can move to faults by default.
Let's go back.
Set it to false here, then take slam lending.
In the end, we're going to choose.
Animation trigger, which allows this enemy to move.
And now if I.
Make him as a prefab.
And then I'm going to delete them from scene and go to game mode.
And place him.
He's going to appear something like this.
Wait a second.
Not as I planned.
Let me try again.
Oh, I know what is happening.
We need to do one more additional condition.
Yeah.
So the deal is we transferring from any state to jump fall and default state player Grand Slam is also
any state.
So we transfer it from this state immediately to jump fall.
And that's why that animation is not working.
We have two choices, as I see now.
Either one is to use can move boolean or another one create new boolean and actually let's make a new
Boolean so we know what is it about.
It's going to be just respond, I'm going to copy this name so I won't forget it.
Or is it?
Going to copy this now From any state to jump fall, we can go only if just respond is false.
All right.
Very good.
Same goes for ledge climb.
Actually, let's do this.
Just respond false.
Just to protect our self.
Yeah.
Now let's go to code and make a boolean private bool.
Just respond.
Which is true by default.
And then once we set him free, once he can run in the animation trigger.
So we have to change this by a bit.
Again, I said, just respond.
False.
So now he's not just respond and we can proceed.
And also we need to assign animator of this boolean so anim.
Said ball of just respond to just respond save this and let's go into unity now.
Can I click, pause, enter play mode and drag one enemy to the scene.
And.
Boom.
That was almost perfect.
The only problem is animation was looped.
Let's go and try to fix it.
Animation player Grand Slam.
Here it is.
Loop time and check.
And let's do the same for Slam London.
When I try again.
Boom.
Okay, now let me try with the pause.
Boom.
Och, Och.
To make him a bit more floaty, we can set his gravity scale to a bit lower value.
And once his velocity is below y we're going to make it back to default.
And if you're going to fall faster, well let's just do this improvement.
Why not?
Private float Default gravity scale.
Then in the start over here, I'm going to do default.
Gravity scale equals store B gravity scale.
Then RB gravity scale equals to RB gravity scale.
Let's multiply it by maybe 0.6 F, So it's going to be on the 60% of gravity scale and in the update.
If just respond and rb velocity that y less than zero then rb gravity scale equals to default gravity
scale.
Yeah.
Now, this will make him a bit more flirty.
And while we are on this, let's make him appear at certain situations.
So how are we going to do this?
Super simple.
We're going to make an empty box collider which will generate enemy when player enters it.
So I'm going to make it empty.
It's going to be enemy respawn.
Position.
All right.
We're going to add Box Collider to it.
So.
Box Collider to DX is going to be a trigger.
We're going to make it really high so Player won't miss it in any case.
Now we're going to make create empty.
Respond position and we need a script for this.
Let's go New script Enemy Creator.
Enemy creator.
And for this we need a couple of things.
We need serialized field, private game object.
Game object enemy prefab and sterilized field private transform respond position.
Then we need a function to make him and we're going to just do on trigger enter to D if.
Collision dot get component of the layer not equals to null.
Then we're going to instantiate enemy prefab and respond position.
Kryptonian Identity.
Respond position.
Dot position, I guess.
Yes.
And it's something simple.
If you want to have a random chance of spawn in it, going to be pretty simple to do.
Serialize field private float chance to spawn.
And just here going to do if random range from 0 to 100 is less or equals than chance to spawn, then
we're going to do this.
Okay, let's go back.
Now, in unity, we need to set up enemy and set up respond position.
Chance to spawn is up to you, but for the testing, I'll set 9 to 9.
So it is very high chance.
And we can make it as a prefab and use it later just to place it in the scene where you want to make
an enemy.
If to be precise, you need to place it on the level part somewhere, let's say here and then here,
something like that.
Let's go and try this.
Oh.
My bad.
Let's take this enemy response position.
Click is trigger and Click override.
Apply all.
Now try again.
He's there.
Oh, they're really fast.
Oh, my God.
Look at them.
They're crazy.
I know.
They're so crazy.
I noticed they jumping out, but they're just at one place.
So what I want to do here is to set their velocity on the X to bigger value once they created so maybe
to ten and 15 on the Y.
And let's try this again.
It looks cool, right?
They're like crazy ninjas who are trying to catch you.
My God.
Why are they not getting any velocity?
The x?
I don't like it.
Oh I know why.
I know why.
Och.
Here is the deal in the movement function.
If can move is false, then we set velocity to zero and because of that they cannot move even in the
start.
So what we can do is actually they move with the start, but then next frame they set velocity to zero
and they cannot move.
So what we can do here is to set if just respond.
Then in return.
Right.
And maybe here we can set just respond to false.
So this will stop their x velocity when they going down, which looks well, we can see how it looks.
Let's try this and test.
Now we should not stop x velocity because it looks weird and also stops boolean of the animator.
Let's delete this.
Now, just in case I want to do something here, I want to select this enemy and change his layer to
a new layer of the enemy.
Enemy.
Now I want to go to edit project settings, find physics two D collision matrix and find enemy and check
with enemy and then check with player.
And actually we can then check with the trap so they won't collide.
Never.
All right.
Even between each other supposed to improve the feel.
I think they could fall faster.
And we could make it.
We could.
We could make RB gravity scale to default grade scale multiplied by two, let's say.
So it's twice more of a gravity.
They're going to fall really fast and at the trigger of the animator because set it back to default
or B gravity scale equals to default gravity scale.
When I see this now.
Now there slide in there.
I can see their slide in.
A he can stop.
He can stand on top of me.
Y y he can do that.
We did exclude it from the layers, right?
Did they override it?
They should be enemy on the enemy.
Okay.
Now they are not colliding, but they are sliding when they hit the ground.
Don't like it.
So let's add a bit more functionality.
Why not?
Just going to just respond.
We do.
This.
And if.
Is grounded, then RB velocity equals to a new vector.
Two is zero zero.
Like that.
Now, this is the final step.
Now, you know, to make it now you know how to place it on the level.
I hope you did like this video as a bonus, content was fun to make it.
Yeah, this looks better.
Look, they slam.
And they collecting all my coins.
So destructible.
Well, you should know that we have a lot of them here because we are testing.
But in the game you can set lower chance and make them spawn.
Not so often it's going to be better.
Look at them catching you up.
Whoa!
It is crazy.
And they stopped because of the distance.
All right.
The last issue I can see here, when they fall in, they're not dying.
It can happen because he stopped his movement and he's very far away from the player platform, disappeared
and he goes down endlessly and potentially we could have thousands of enemies created and stay in there.
So and the place we created them.
Let's do something different here.
We can do Game object new enemy equals to instantiate and then destroy new enemy within, let's say,
60 seconds, right?
Why not?
And this object, enemy creator are going to be destroyed with the level part.
So it's fine.
So in a 60 seconds, we're going to destroy them.
Maybe even less.
Maybe just 30 seconds.
I think it's okay.
Yeah.
Once again, thank you for completing the course.
I guess it was pretty big journey for you, like 12 hours or something of the content and you did it.
You made a game.
Very nice.
I'm proud of you, man.
Proud of me for creating it.
And keep in touch.
You can text me messages, you can type, especially if you like.
You can write comments on YouTube.
It would help me a lot and subscribe to my YouTube and do it.
Do it.
Just do it.
I'm going to show it to you.
Baron is supposed to be the very good channel.
I, I try hard on it, except at the time when I'm creating courses.
When I'm creating courses, I'm not posting videos here.
As of now, I'm creating this RPG game, trying to make it cool and nice.
Yeah.
So subscribe to the channel, leave the comments there, ask you questions if you need to.
Thank you for purchasing the course.
Check out links in the description for promotional prices and I'll see you later.
Bye.