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
Hey, hey in this video, we're gonna be creating a simple defender that has some 3
3
animation and maybe changes color a little bit. 4
4
And an animation event that says, 5
5
this is the point where we want it to shoot out some sort of projectile. 6
6
So that in upcoming videos, we can have our defenders actually do defending. 7
7
So let's jump in and set up a simple defender prefab. 8
8
A quick tidy up, I'm gonna creat a empty game object. 9
9
An empty game object to use better grammar and I'll call this Sporners. 10
10
Reset the transform of that and then just place my five Sporners underneath that. 11
11
So just tidy it up a little bit, there we go. 12
12
Lovely and my trophy. 13
13
Have we prefabbed the trophy? 14
14
Yes, we have. 15
15
So I just removed the trophy from the scene for now. 16
16
Well, actually, nope, I'm going to leave it there. 17
17
So we keep it tidy and we don't have things getting in the way, but 18
18
it's sometimes good to have a visual representation in a point of comparison. 19
19
So let's leave it in there, okay? 20
20
So what we need to do is start off with a big old challenge, 21
21
cuz I think you're ready to take on all these aspects. 22
22
That's creating a defender, the animations and animated controller. 23
23
So slice up the sprite sheet, what I'm gonna do is choose. 24
24
Let me see, so we do this together from my not in use. 25
25
I'm gonna create cactus. 26
26
So let me just create a new folder here. 27
27
Cache, cache does. 28
28
Okay and then from my not in use, I'm gonna grab cactus distitle and 29
29
cactus dislooping and drag this in to cache this. 30
30
Okay, so slice u your sprite sheet, the one that I was selecting they are not 31
31
the ones and create an idle animation from the idle animation sprite sheet and 32
32
create an attack animation from the attack animation sprite sheet. 33
33
And then to add an animation event when you feel that the defender should shoot 34
34
a projectile at that to the attack animation, an animation event and 35
35
then to create an animated controller where we start off in idle animation and 36
36
then just go straight into attack. 37
37
So at the moment we won't have any sort of trigger to say to go from idle to attack, 38
38
but we'll have our shape set up, so we're ready for that. 39
39
So it's a pretty meaty challenge, jump in. 40
40
Take that on, I'll see you back here when you've got that done or 41
41
you can do it at the same time. 42
42
I'm doing it just now, if you'd like to do that. 43
43
Okay, let's see. 44
44
So we've got our idle and I'm going to slice it up. 45
45
Change my sprite mode to multiple, click on Apply. 46
46
Now let's have a look at this. 47
47
Cactus Idle and take note it's 924 by 1008. 48
48
Get out my calculator, Calculator, cuz I'm gonna slice by grid. 49
49
This will be not, how many have we got? 50
50
One, two, three, four, five, six. 51
51
So 942 divided by 6 equals 157. 52
52
I'm gonna write that down on my bit of paper here and 53
53
then 108 divided by 1, 2, 3, 4, 5, 6, 54
54
7, 8, 1008 divided by 8 is 126. 55
55
Now, we go into sprite editor. 56
56
Go up to slice, change this to grid by cell size and 57
57
we'll change this to 157 by 126. 58
58
I've done this before, so it should be pretty familiar. 59
59
That's all looking pretty good with just a little bit of a cycle through. 60
60
Yeah, that looks good. 61
61
Okay, it's all looking pretty good. 62
62
Nothing's been chopped off at all looks in a good spot. 63
63
Okay, then click on Apply. 64
64
Nice, close that out for now. 65
65
We have our sprite sheet sliced up. 66
66
I'll go and slice up the other one for now while I'm here. 67
67
The cactus looping, otherwise known as the Cactus Attack. 68
68
Sounds like a bad movie, doesn't it? 69
69
Multiple, [LAUGH] click Apply. 70
70
Click on the sprite editor. 71
71
This is different again, okay. 72
72
Let me find the cactus looping, the dimensions here. 73
73
So left to right, we've got one, two, three, four, five, six. 74
74
This has got a lot of images on it, hasn't it? 75
75
So this is 942 that I'm getting from 76
76
down here in the dimensions divided by 6. 77
77
That's 157 again. 78
78
Okay, that makes it easy and then it is 1638. 79
79
I think this is gonna be exactly the same. 80
80
1638 divided by 1, 2, 3, 4, 5, 81
81
6, 7, 8, 9, 10, 11, 12, 13, 126. 82
82
Yes, it is exactly the same. 83
83
Okay, great. 84
84
157, 126, slice that up. 85
85
It all looks pretty good. 86
86
Click on Apply and job is done, fantastic. 87
87
Did you play the old Warcraft games way back in the day? 88
88
Warcraft II, job's done. 89
89
That's how the peasant used to say that they'd finished their job. 90
90
That's what I thought of just now and I'm saying job done. 91
91
Okay, Cactus Idle, highlight all of the Idle frames, 92
92
right-click, create animation. 93
93
There it is. 94
94
Animation, we'll call this Cactus Idle. 95
95
Drag my Cactus Idle animation to my animation folder. 96
96
Now we will create our next animation which will be cactus looping, 97
97
highlight all of these frames. 98
98
There's ton of them, 63 and then create animation and 99
99
we'll call this Cactus Attack, Cactus Attack. 100
100
There we go, drop that into the animation folder as well. 101
101
Soon, we'll need to organize this. 102
102
Actually, it's getting pretty close. 103
103
I'm gonna organize this into attackers and defenders, so create a new folder. 104
104
Attackers and then another folder, defenders. 105
105
And then the cactus goes into attackers and 106
106
the lizard goes into, sorry attacks. 107
107
God, I've got everything wrong here. 108
108
It's attackers. 109
109
Rick, you dingbat and then we need to, did I just put them in there? 110
110
Okay, so the cactus is a defender. 111
111
Thank you for those of you yelling at the screen. 112
112
Rick, what are you doing? 113
113
And then we have the trophy, which technically is a defender. 114
114
It's one of the goodies. 115
115
Okay, here we go. 116
116
Now that we've done that, let's while we're here, 117
117
let's just quickly create our animated controller. 118
118
So right-click, Create > Animator Controller that 119
119
we'll call cactus and then click on the animator window. 120
120
This should be the animator controller for the cactus. 121
121
Yes, it looks like it indeed. 122
122
Excellent, what do we need to do next? 123
123
Well, we need to create a game object. 124
124
I didn't have that on my list, hopefully you figured that out and found it. 125
125
So right-click, create empty this will be called cactus. 126
126
Reset the transform back down to zero, zero. 127
127
We need to give this a sprite render, so 128
128
we can see what it looks like and see where it is in the game. 129
129
Now pick one of our frames, so go to cactus for the sprites. 130
130
Which one do we wanna have represent just how the cactus looks normally? 131
131
Cactus one just fine and dandy, and 132
132
we will drag Cactus Looping_1over onto our sprite. 133
133
There we go. 134
134
Now change the border to five, that's all the same. 135
135
Great, that looks pretty good. 136
136
Moving on to the thing might be a tiny bit too big, but I'll leave it big for now. 137
137
You can have a little bit of overlap, perhaps and see how that goes. 138
138
You can change that pretty easily later on just by changing out pixels per unit in 139
139
our spreadsheet. 140
140
So here we go. 141
141
We've got a cactus on the screen. 142
142
We've got some animations. 143
143
Let's go back to our animated controller in defenders. 144
144
Okay, got cactus here. 145
145
Cactus dragging, our cactus first of all, dragging the idle, Cactus Idle. 146
146
Blink, that creates that as it's first step and then Cactus Attack. 147
147
We'll do the same as we did before where we say, right-click from Cactus Idle, 148
148
make transition into Cactus Attack. 149
149
At the moment there's no condition for when it should go into there, 150
150
it'll just go straight in there after it finishes doing its Cactus Idle. 151
151
Have a look at the transition and just clean that up a little bit. 152
152
I like to have a 0 transition for these 2D assets. 153
153
Get that out of the way, that's pretty good and then the exit time of one. 154
154
Great, great stuff. 155
155
Okay, Cactus Idle, let's make sure it is not looping in our animation. 156
156
Yep, that's correct and then cactus attack. 157
157
We'll leave that looping, I think and loop that. 158
158
Okay, that should be all pretty good. 159
159
Last bit here is we need to say that we need an animator on our cactus. 160
160
Animator and then what's our animator controller? 161
161
Click on selector, it will be the cactus. 162
162
Now all going to plan, that should animate our cactus that goes from idle And 163
163
the idle and the attack are pretty similar. 164
164
Well, that's very slow. 165
165
And then [SOUND] okay, so again, I wanna speed that up a whole bunch. 166
166
Let's go and have a look at that. 167
167
Cactus Idle for the moment for animation is 12 frames per second and 168
168
we've got tons, and tons of frames. 169
169
Okay, so let us change that to, 170
170
make it 24 like our other ones and then the cactus attack. 171
171
We'll make that 24 as well just have a look at that. 172
172
Make sure it's all looking nice and neat, and tidy. 173
173
So bounce, bounce, a little bit of bounce. 174
174
And then now I'm gonna shoot. 175
175
Okay, that's looking pretty good and then it loops around. 176
176
What I'll do in here just add one little bit of flair into our attack, 177
177
if I can get this happening is if I click on the cactus attack animation which I am. 178
178
I'm gonna click on Record. 179
179
It's not letting me do that, because I need to click on my cactus, and 180
180
now it should let me record. 181
181
Yes, click on Record. 182
182
Move it to where I think it should shoot. 183
183
Sorry, I'm on idle at the moment just change the selection here to attack. 184
184
Now, click on Record and move it up to, maybe it's gonna go. 185
185
[SOUND] Okay, [SOUND] so the animation's not really made for 186
186
shooting bullets, but maybe just as it opens its mouth wide up there. 187
187
So what I'll do is I'll add an animation even in a moment. 188
188
Actually, I'll do that right now just click my animation event. 189
189
We'll come back to that in a moment. 190
190
What I'm gonna do in here is just change the color of my sprite renderer on 191
191
the cactus. 192
192
So we will have it build up to some sort of bright color. 193
193
Watch we have it build up to a red. 194
194
It's gonna be a little bit ugly, my friends, but that's okay. 195
195
Maybe build up to a bright green and then I'm going to move back a little bit here. 196
196
So we've got a key frame and then move back to here a little bit on my selection, 197
197
and put that back to normal white. 198
198
So then, turn off my record mode. 199
199
It should go normal, normal, normal and then bright green and then blunk. 200
200
Okay, it stayed on bright green. 201
201
So I wanna have it after it shoots. 202
202
I wanna have it go back to being white again or no tinting as the case might be. 203
203
Okay, so I'll click on Play, see how this looks. 204
204
[SOUND] And then building up and then down, building up and down. 205
205
So you could put a little bit of a flash at the end there just as it shoots. 206
206
It could be yellow, for example. 207
207
But this is gonna give the player a little bit of visual flair. 208
208
So there's a lot more you can do for color. 209
209
I think this is pretty interesting white add some depth to this bright. 210
210
So we've got, now we have our animation event and I believe that's looking 211
211
a littler bit different as were expecting as we don't have any script on our cactus. 212
212
And a defender script as we have with our lizard, we've got another script on there. 213
213
So it's looking a little bit different, our animation event. 214
214
So we'll leave it for now. 215
215
We've got everything setup that we wanted to setup. 216
216
This was just a quick little video to say, let's get our. 217
217
Defender ready and raring. 218
218
We've out or event in there. 219
219
That's the point where we want to say this is where you shoot. 220
220
Okay, that's looking pretty good. 221
221
We've got our defender. 222
222
Last step of prefabbing that, so drag our cactus down into your prefabs. 223
223
We'll do a little bit more work on the cactus, so 224
224
I'll leave it up here in our hierarchy. 225
225
Good stuff, so we're ready to create some functionality where the cactus will shoot 226
226
and be damaged and have health all of those things. 227
227
So great work 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.