In this video, we're going to make speed reset function.
Let's go to player, find our speed controller and maybe just above create private void speed reset
and we'll leave it for now.
Let's go above.
So to reset the speed, we need to know to what value we reset in the speed.
So we need to save default value how we can do that very, very simple.
First, we create a variable private float default speed, and we need to create a default milestone
increase for as well.
So private float default milestone increase because this all what we need.
Now let's go to start function and say that.
Our default speed is equals to mode speed.
And our default milestone increase equals to milestone increase.
Just like that.
So now we have default value saved, and no matter what we write in the inspector, every time we start
the game, we'll have default value here.
And then in the speed reset, we say that move speed equals to default speed and milestone increase
our equals to default milestone increase.
Now, whenever we need to reset speed of the player, we can just call this function.
And good example would be when we face in the wall.
Let's go to the movement and say if ball detected, then we do a speed reset and then return.
Save it.
Let's go back.
I'm going to run for a while.
To get my speed.
So now my speed is.
20.
Now I want to place a wall in front of the character.
Let me find any place it here.
Maybe one here.
So I can jump on it and won over here so I cannot avoid it.
Oh.
Anyway, now let's check my speed.
Most be 12.
What if I try to run again?
Does it work?
Let's see.
Yeah, it does go right.
Now we can go and create the region for this region.
Speed.
Control.
And close the region over here and region.
And then it's over.
Now, let's go to next video.