1
00:00:00,000 --> 00:00:02,000
In this video, we're going to make speed reset function.

2
00:00:02,000 --> 00:00:11,000
Let's go to player, find our speed controller and maybe just above create private void speed reset

3
00:00:11,000 --> 00:00:12,000
and we'll leave it for now.

4
00:00:12,000 --> 00:00:14,000
Let's go above.

5
00:00:14,000 --> 00:00:19,000
So to reset the speed, we need to know to what value we reset in the speed.

6
00:00:19,000 --> 00:00:24,000
So we need to save default value how we can do that very, very simple.

7
00:00:24,000 --> 00:00:31,000
First, we create a variable private float default speed, and we need to create a default milestone

8
00:00:31,000 --> 00:00:32,000
increase for as well.

9
00:00:32,000 --> 00:00:39,000
So private float default milestone increase because this all what we need.

10
00:00:39,000 --> 00:00:42,000
Now let's go to start function and say that.

11
00:00:43,000 --> 00:00:47,000
Our default speed is equals to mode speed.

12
00:00:48,000 --> 00:00:53,000
And our default milestone increase equals to milestone increase.

13
00:00:54,000 --> 00:00:55,000
Just like that.

14
00:00:55,000 --> 00:01:01,000
So now we have default value saved, and no matter what we write in the inspector, every time we start

15
00:01:01,000 --> 00:01:03,000
the game, we'll have default value here.

16
00:01:03,000 --> 00:01:12,000
And then in the speed reset, we say that move speed equals to default speed and milestone increase

17
00:01:12,000 --> 00:01:15,000
our equals to default milestone increase.

18
00:01:15,000 --> 00:01:19,000
Now, whenever we need to reset speed of the player, we can just call this function.

19
00:01:19,000 --> 00:01:22,000
And good example would be when we face in the wall.

20
00:01:22,000 --> 00:01:28,000
Let's go to the movement and say if ball detected, then we do a speed reset and then return.

21
00:01:28,000 --> 00:01:29,000
Save it.

22
00:01:30,000 --> 00:01:31,000
Let's go back.

23
00:01:31,000 --> 00:01:33,000
I'm going to run for a while.

24
00:01:33,000 --> 00:01:35,000
To get my speed.

25
00:01:49,000 --> 00:01:51,000
So now my speed is.

26
00:01:52,000 --> 00:01:53,000
20.

27
00:01:53,000 --> 00:01:57,000
Now I want to place a wall in front of the character.

28
00:01:57,000 --> 00:02:00,000
Let me find any place it here.

29
00:02:00,000 --> 00:02:02,000
Maybe one here.

30
00:02:03,000 --> 00:02:07,000
So I can jump on it and won over here so I cannot avoid it.

31
00:02:09,000 --> 00:02:10,000
Oh.

32
00:02:10,000 --> 00:02:12,000
Anyway, now let's check my speed.

33
00:02:15,000 --> 00:02:16,000
Most be 12.

34
00:02:16,000 --> 00:02:19,000
What if I try to run again?

35
00:02:20,000 --> 00:02:21,000
Does it work?

36
00:02:21,000 --> 00:02:21,000
Let's see.

37
00:02:22,000 --> 00:02:24,000
Yeah, it does go right.

38
00:02:26,000 --> 00:02:29,000
Now we can go and create the region for this region.

39
00:02:29,000 --> 00:02:30,000
Speed.

40
00:02:32,000 --> 00:02:33,000
Control.

41
00:02:34,000 --> 00:02:38,000
And close the region over here and region.

42
00:02:40,000 --> 00:02:42,000
And then it's over.

43
00:02:42,000 --> 00:02:44,000
Now, let's go to next video.

