1
00:00:00,000 --> 00:00:01,000
Hello, guys.

2
00:00:01,000 --> 00:00:03,000
Welcome to new video.

3
00:00:03,000 --> 00:00:08,000
And in here we're going to make character run and I mean animation.

4
00:00:08,000 --> 00:00:09,000
We're going to make a running animation.

5
00:00:10,000 --> 00:00:16,000
Let's go to animation window over here and create new clip in the animations folder.

6
00:00:16,000 --> 00:00:23,000
It's going to be player move, save it, go to graphics player and run.

7
00:00:23,000 --> 00:00:26,000
Let's take all of these sprites and drag them here.

8
00:00:27,000 --> 00:00:29,000
And I'm going to set sample rate 12.

9
00:00:29,000 --> 00:00:33,000
Later on we're going to change the animation speed according to the speed of the player.

10
00:00:33,000 --> 00:00:35,000
But for now, let's just keep 12.

11
00:00:35,000 --> 00:00:41,000
Now if we go to animator, we can see that animation is there, but it's not connected to the main tree

12
00:00:41,000 --> 00:00:42,000
anyhow.

13
00:00:42,000 --> 00:00:45,000
And now we cannot use it, but we want to use it.

14
00:00:45,000 --> 00:00:47,000
And to do that we're going to use parameter.

15
00:00:47,000 --> 00:00:53,000
So let's hit this plus icon and we can choose one of four and I'm going to choose boolean that will

16
00:00:53,000 --> 00:00:56,000
be named as ease running.

17
00:00:58,000 --> 00:01:02,000
Now let's make transition from idle to move and from move to idle.

18
00:01:02,000 --> 00:01:06,000
If we select this transition on the right side, we can see condition for it.

19
00:01:06,000 --> 00:01:11,000
So let's set condition for one true and for another one false.

20
00:01:12,000 --> 00:01:14,000
Now let's try that.

21
00:01:14,000 --> 00:01:15,000
Let's go to play mode.

22
00:01:15,000 --> 00:01:17,000
Have Bullen over here and if I check it.

23
00:01:18,000 --> 00:01:21,000
I can see I'm running if I check it again.

24
00:01:21,000 --> 00:01:22,000
I am not running.

25
00:01:22,000 --> 00:01:26,000
And if you notice, there are a slight delay between animations.

26
00:01:27,000 --> 00:01:28,000
To fix that.

27
00:01:28,000 --> 00:01:30,000
We're going to select this transition.

28
00:01:30,000 --> 00:01:34,000
Open settings and and make transition duration zero as well.

29
00:01:34,000 --> 00:01:38,000
We want to uncheck exit time and same for another one.

30
00:01:38,000 --> 00:01:43,000
Now, if I go to play mode and check this box, my transition is instant.

31
00:01:43,000 --> 00:01:49,000
Our next step would be make this transition from the code so we don't have to click this checkbox manually.

32
00:01:49,000 --> 00:01:53,000
We can do that by going to script again and maybe in the update.

33
00:01:53,000 --> 00:01:58,000
Let's create a boolean and I'll just make it public because we need it real quick.

34
00:01:58,000 --> 00:02:03,000
Public is public, bool is running now.

35
00:02:03,000 --> 00:02:06,000
Let's go to update and type anim set.

36
00:02:06,000 --> 00:02:06,000
Bool.

37
00:02:07,000 --> 00:02:11,000
So you know what we do in rate animals is.

38
00:02:13,000 --> 00:02:14,000
This.

39
00:02:15,000 --> 00:02:16,000
Animator.

40
00:02:16,000 --> 00:02:16,000
This one.

41
00:02:17,000 --> 00:02:18,000
Let me open it.

42
00:02:18,000 --> 00:02:22,000
So this animator is exactly this animator.

43
00:02:23,000 --> 00:02:25,000
And if we go back to code.

44
00:02:26,000 --> 00:02:27,000
We know that.

45
00:02:29,000 --> 00:02:38,000
This animator is exactly this animator because we get an access to, again, this animator from here.

46
00:02:39,000 --> 00:02:40,000
Got it.

47
00:02:40,000 --> 00:02:41,000
Cool.

48
00:02:41,000 --> 00:02:47,000
Now we're saying anim set, bool, and we need the name of Bolan and we know that name is is running

49
00:02:47,000 --> 00:02:50,000
and let's set it to value of is running.

50
00:02:53,000 --> 00:02:59,000
Now, if I go back to Unity and hit play and can see my character standing, if I check this box is

51
00:02:59,000 --> 00:03:02,000
running here going to run and again and again.

52
00:03:04,000 --> 00:03:07,000
So we control this balloon by controlling this balloon.

53
00:03:07,000 --> 00:03:13,000
Now all what we need to do is to control this balloon according to the speed of the player, not by

54
00:03:13,000 --> 00:03:14,000
clicking the mouse.

55
00:03:14,000 --> 00:03:15,000
So let's go back.

56
00:03:15,000 --> 00:03:23,000
And in the update, I'm going to type is running equals to RB dot velocity, dot x, not equals to zero.

57
00:03:25,000 --> 00:03:26,000
OC.

58
00:03:26,000 --> 00:03:28,000
And I can make it private.

59
00:03:30,000 --> 00:03:30,000
Private.

60
00:03:31,000 --> 00:03:34,000
So now this boolean will be true only.

61
00:03:34,000 --> 00:03:38,000
If velocity of the x not equals to zero.

62
00:03:38,000 --> 00:03:40,000
Now let's go back and check it in the action.

63
00:03:43,000 --> 00:03:45,000
Yeah, works.

64
00:03:45,000 --> 00:03:48,000
And now, before we finish this video, let's do a bit of clean up.

65
00:03:49,000 --> 00:03:54,000
What I want to do here is I want to create a function for animations only.

66
00:03:54,000 --> 00:04:01,000
So let's select this click alt enter to call submenu, and we're going to choose extract method.

67
00:04:01,000 --> 00:04:05,000
I'm going to name this as animator.

68
00:04:05,000 --> 00:04:07,000
Controllers.

69
00:04:08,000 --> 00:04:10,000
OC save it.

70
00:04:10,000 --> 00:04:13,000
And I think that's enough for this video.

71
00:04:13,000 --> 00:04:14,000
Let's go to the next one.

