Hello guys.
Welcome to a new section.
In this section we're going to develop lots of new mechanics lots of cool things.
Just want to show you how to work with the, you know triggers timers.
They're going to be so many different stuff we're going to do.
And I really believe this will help you to learn a lot about the development.
So I'm going to start with simple.
I want to make a very simple trap.
Let's go to graphics traps.
And over here we have this spikes folder.
It is a very simple trap but still we can use it.
So I'm going to just take the sprite sheet.
Let's make pixel per unit 16.
And then let's take the image and drag it into the scene, just like so.
I want to rename it to.
Trap spike, and I think it should be in front of a background but behind the ground itself, so we
can nicely place it.
Because of that, I'm going to go to Sprite Renderer, choose Search and Layer Traps, and I want to
click over here and adjust order over here.
I'm going to place traps above the ground.
So now traps will always be behind the ground and we can place it like this maybe.
Yeah this is just good.
Now let's give it a circle Collider.
Maybe we only need to move the collider down.
We can do it by using offset over here.
Just going to do -0.40 .50.3.
Let's do 0.4.
It's okay.
This looks fine to me.
Maybe a bit to the left.
Hmm.
Yeah, something like this will do.
I like it, and we need to set it to a trigger.
And after that we need to add damage.
Trigger script.
Very cool.
Now let's go to play mode and see if it's working.
I'm pretty sure it does.
Okay.
Very cool.
So we have a knockback.
Now I want to do something here.
I want to change the behavior of a knockback.
As of now we have knocked back set 2.7 and if it has longer value, then we're going to exit the knockback
animation.
Not very nice.
I want to make it as flexible as possible.
That's why we're going to go to animator of a player.
And in the numerator we're going to change this knockback trigger to a boolean.
Let's delete it.
And let's add boolean is knocked.
Okay.
Then over here, instead of doing the condition with the trigger, we're going to choose is knocked
and exit from this animation.
Going to be is knocked.
False.
Just like that.
Also, let's make sure we have a loop on the animation.
So I'm going to select this.
Find the motion, select it and check if we have loop time.
We have it so it's fine.
Now let's go to the script of a player.
We need to find knockback.
Coroutine.
It is over here.
We can remove this set trigger.
And over here I'm going to do enum.
Set bool.
Is knocked to true.
And then after this I can do enum set bool.
Is knocked to false.
Very good.
Actually, we could just, you know, use the is not boolean itself over here.
We could do like so but it doesn't make any difference.
So I'm going to keep it uh, with what I can read better.
All right.
Let's go ahead now.
And let's set knockback duration to some big value like three seconds.
I just want to make sure it is working.
Gonna go and hit the trap and boom!
Okay, I like it.
I think we need to do something here on the animator.
Let's go and uncheck exit time.
As exit time uncheck.
This is better.
Now I'm going to bring back duration of a knockback to something like 0.75.
And I'm going to keep it for now.
Um there is something else I want to improve real quick.
I want to take all of the animations of the player and make simple rate 20.
So I'm going to just go over here and do Simple Rate 20.
Sample rate.
20.
I think it will look better anyway.
The knock.
20.
Move, respond and we'll slide 20.
Okay.
Let's go to the game window.
Looks nice.
Okay.
Maybe I'll make it a bit lower.
Point six.
Good.
Let's go to the next video now.
I'll see you there.