Afrikaans
Akan
Albanian
Amharic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
1 1
[MUSIC] 2
2
In this video, we're gonna create the two extra states of running and 3
3
climbing to go along with our idling state. 4
4
And I'll introduce you to transitions. 5
5
We'll make some parameters so that we can transition from one state to another 6
6
simply by clicking the checkbox here to show now my character is climbing, and 7
7
now my character is running. 8
8
Let's jump in and get started. 9
9
Okay, let's navigate our way to the sprite sheet for the character. 10
10
We can see it there. 11
11
We've got a bunch of sprites to choose from. 12
12
What we're going to start off with is running, I think. 13
13
So we're gonna scroll down and look for the running. 14
14
I'm just gonna go and open up the sprite sheet itself so 15
15
I can see where that goes from. 16
16
If I look in there, it's this bottom one here that's the run animation. 17
17
So it'd be the very last frame starting from 19 and going until 28. 18
18
So that's gonna be our run. 19
19
Don't worry about doing that. 20
20
Okay, so let's go find 19 in our sprite sheet here, 15, 16, 17, 18, 19. 21
21
As we did before, we're gonna highlight everything all the way down 22
22
to the final one down here, right-click, Create > Animation. 23
23
We'll call this Running, wonderful. 24
24
Now from here, we can, as we did before, 25
25
drag that into our Animator, Animator Controller. 26
26
We have this state of Running that at the moment consists of our running animation 27
27
and not much else. 28
28
While we're here, let's click on Running and make sure we loop that and 29
29
drag Running into the Animations folder. 30
30
So now we have Running and Idle. 31
31
As a piece of consistency, I'm gonna rename Idle to Idling. 32
32
It's not really a word, but 33
33
I wanna have my states very clearly be the thing that you are doing at the moment. 34
34
You're running at the moment, you're climbing at the moment, 35
35
you're idling at the moment. 36
36
So that's super duper clear on that. 37
37
Okay, now we have our Running state. 38
38
We need to make a transition from Idling to Running so 39
39
that we can say what needs to happen for 40
40
the player to stop being in an idling state and start being in a running state. 41
41
To make a transition, right-click on the state, click on Make Transition and 42
42
then you'll have this arrow that you can point elsewhere. 43
43
We'll point over the Running and left-click on there. 44
44
So now I have a state transition leading into Running. 45
45
If you click on the arrow itself or 46
46
the line itself, let me show you what's going on with that transition. 47
47
There's a couple of things in here to have a look at. 48
48
First of all, we've got a little bit of blending that 49
49
Unity is trying to do from one state to another. 50
50
Now that ends up looking a little bit crumby because we've got nice, 51
51
clean 2D animation here. 52
52
We don't need it to blend as we might do with 3D animation. 53
53
So I'm going to open up Settings and 54
54
just turn Exit Time to 0 and the Fixed Duration to 0 as well. 55
55
Now there won't be any of that blending that needs to take place. 56
56
So we can probably just do the transition duration if we wanna be 57
57
a little bit quicker about it. 58
58
So we've put that to 0. 59
59
Now we have this movement into Running. 60
60
We need to say what condition is going to be met for this trigger to take place. 61
61
So in our Animator window, make sure Parameters is clicked. 62
62
We're gonna click the + icon just here, and we've got a choice of Float, Int, 63
63
Bool, and Trigger. 64
64
For now we're going to set up a Bool, and this Bool we will call Running. 65
65
We come back over onto our Conditions. 66
66
Make sure you have your transition selected here, click +. 67
67
And the only condition we've got at the moment is Running. 68
68
That's the only one we've set up over here. 69
69
And Running is true. 70
70
So basically, it's saying when the Bool of Running is true, 71
71
then we transition into the state of Running. 72
72
That's pretty straightforward. 73
73
If we click on Running, right-click, 74
74
Make Transition, we can transition back to Idling. 75
75
And a micro challenge for you. 76
76
What's the condition where we will transition from Running back to Idling? 77
77
That would be + Running is false, of course. 78
78
Same as before, I'm gonna make the Transition Duration 0 79
79
just to make sure we don't have any of that overlap here. 80
80
I'll put this to 0 as well, okay, just so it's nice and clear this is gonna happen. 81
81
I just click straight into that other state without any blend. 82
82
Okay, so now we've got that flow going on. 83
83
This is all hooked up to the player still cuz the player has the Animator Controller 84
84
in here called Player, so it knows this straight away. 85
85
If we click on Play, you should see the player sitting there idling. 86
86
I'll just go back to my Scene view so I can get in nice and close. 87
87
The player's sitting there idling. 88
88
If we click on this, this is to simulate if we were to call it in code and 89
89
say, turn the Bool to true. 90
90
Now the player's running, run, run, run, run, run. 91
91
And then if we click on it to simulate, 92
92
now code's saying turn the Bool to false, then back to animation again. 93
93
So we've got this nice flow from state to state, very excellent. 94
94
Now the next state we're going to set up is going to be the climb ladder. 95
95
That's the other main state we'll have in our game. 96
96
Let's just go have a look at our sprite sheet to see which one that would be. 97
97
Climb ladder is pretty much just gonna be these two here. 98
98
So 14 and 15, I've got those in my sprites here. 99
99
So what I want you to do as a challenge is to implement climb and 100
100
run animation states, create the transitions from idle, and 101
101
create the triggers for each of the states. 102
102
So go ahead and do that for climb and run, and 103
103
I'll see you back here when you've got that done. 104
104
Okay, so it was 14 and 15, I believe. 105
105
Let's find those. 106
106
There's 14 and 15 [SOUND] excellent, looks like a wonderful ladder climbing. 107
107
Right-click, Create > Animation, if I can find it, there it is, Animation. 108
108
This will be Climbing animation. 109
109
Drag that into our state machine in here. 110
110
From Idling, right-click, Make Transition into Climbing. 111
111
And I'll do the other one straight away, Make Transition back to Idling. 112
112
Click on this first one and just tidy up little of this. 113
113
You don't have to tidy up the blending, but as I've mentioned, 114
114
I like to do this, dot dot dah, wonderful. 115
115
Click on the + button and create another Bool, which will be Climbing. 116
116
Climbing is our parameter. 117
117
Then over on here, 118
118
our condition going from Idling to Climbing should be Climbing is true. 119
119
And then if we click on the other direction, 120
120
the condition of Climbing should be false. 121
121
And again, just tidy this up. 122
122
Okay, and you can see in here, we've got something that's called Has Exit Time. 123
123
Basically, this is saying, 124
124
you've got a number of ways of exiting this animation state. 125
125
One way is if you want the animation to play. 126
126
And then as soon as the animation finishes playing, 127
127
go back or transition back to the state. 128
128
Then you can use Exit Time. 129
129
So it said there's ten frames of animation. 130
130
You do those ten frames. 131
131
If Has Exit Time is on, 132
132
after the ten frames, it can return back to the other state. 133
133
So I wanna click Has Exit Time off cuz what we're using here is the condition of 134
134
the Bool to say when the transition takes place. 135
135
Have a look over here, turn off Has Exit Time there, and 136
136
same with all these other ones, just turning off Has Exit Time. 137
137
We only want that in a situation where we definitely end after we play a particular 138
138
single shot animation. 139
139
Now let's click Play, see if we've hooked all this up correctly. 140
140
The character should be defaulting to Idle. 141
141
And you can see the Idle clicking through here. 142
142
This is the state we're in. 143
143
It's playing through the frames. 144
144
We click on Running, yes, it runs. 145
145
And Climbing, no, it's not climbing at the moment. 146
146
What have we done wrong here? 147
147
Let's have a look at our transitions. 148
148
We have Running is true. 149
149
You're probably yelling at the screen, saying, Rick, you put in Running. 150
150
You should've put in Climbing. 151
151
There we go, we've found it. 152
152
Let's click Play here. 153
153
Thank you for yelling at the screen, 154
154
if you did yell at the screen in that instance, Climbing, yep. 155
155
And it's stuck, which says that we are not looping, if I am correct. 156
156
We haven't clicked on looping time in there. 157
157
That stays in play mode, which is all good. 158
158
Now that we've got it, our character can run and our character can climb. 159
159
So these are all the states that we need for now. 160
160
As our game gets more complex, we might wish to add in rolling or shooting or 161
161
jumping. 162
162
But for now, 163
163
all we need functionality-wise is the player can run and the player can climb. 164
164
And after we put all of that gameplay functionality in, 165
165
we might revisit our states in here and our animations and add more in. 166
166
But we don't want to overinvest in this until we've got our core gameplay created 167
167
and we know how it all fits together and how it looks. 168
168
So great work in this video, and I'll see you in the next video.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.