All language subtitles for 29. Set & Place Selected Defender

af Afrikaans
ak Akan
sq Albanian
am Amharic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

1 1

[MUSIC] 2

2

Hello, again in this video, we're gonna be able to click on our defenders and 3

3

place down different defenders where we want them to be on the grid. 4

4

So, let's jump in and get started. 5

5

Let's start by taking a look at the scripts that we'll be using in the next 6

6

few videos, and the scripts we need to make everything work. 7

7

We need a Defender Spawner, Star Display, Defender, and Defender Button. 8

8

The Defender Spawner is gonna be responsible for 9

9

storing whoever the defender is that is being selected. 10

10

So whoever is being clicked on, 11

11

we need to find the cost through the Defender Spawner. 12

12

Find if we have enough stars. 13

13

So we need to make sure that if the bank is empty, 14

14

we don't let people place down a defender. 15

15

We need to tell the stars to be spent. 16

16

So over in our Star Display, we haven't created yet, but we will create a script 17

17

that will allow us to have a reference for what the current resources are. 18

18

How many money you have in the bank, and then to answer the question of do you have 19

19

enough stars to buy a particular defender and to spend the stars,. 20

20

So therefore to decrease the number of resources 21

21

as well as increasing spend stars and increase stars. 22

22

And then we need a Defender script and that's gonna provide the cost. 23

23

So a cactus costs this amount and a trophy costs that amount, for example. 24

24

And then the Defender Button, which we've been working on. 25

25

This is where we're setting the defender prefab, so when you click the button, 26

26

it says, this particular defender is the defender. 27

27

That's who we're interested in as their prefab. 28

28

Next up, what I'm wanna do is create a script that says, you're a defender. 29

29

So, right click Create > C# script, which we will call Defender. 30

30

We're not going to do a lot in this script just yet, but I want to have it around. 31

31

So, double click to open up in Visual Studio, I wanna have it around so 32

32

that I can be tagging things as type Defender as well. 33

33

That's gonna be very useful, so we're being specific with the type. 34

34

So, in here, what you will do is straight out, what? 35

35

Pretty simple, we're just going to start by getting rid of our Start and 36

36

Update methods, don't need those. 37

37

I'll create a SerializedField, really simply, 38

38

integer and we'll call this starCost. 39

39

Star is the currency that I'm using, so you could be coins or moolah or 40

40

schmeckles, whatever you want. 41

41

StarCost = 100 is how I'll start that off. 42

42

So that means for each defender we can say how many stars they cost. 43

43

We'll go back over, 44

44

we'll find our trophy and drag our Defender script onto the trophy. 45

45

At the parent level, same with the cactus, 46

46

drag our Defender script on to the parent level of the cactus, okay. 47

47

So these are now defenders through the night for 48

48

the fact that they have to Defender class or Defender script sitting on them. 49

49

Next we're gonna jump into the Defender Button script and 50

50

do a little bit of work in here. 51

51

First thing we need to do is create a notion of who is 52

52

the prefab you have selected. 53

53

At the moment we've got cactus and trophy, but we need to serializeField and 54

54

then I'll type Defender and that will complete because we've gone and 55

55

created type Defender just now with our class, with our script, 56

56

and we will call this defenderPrefab semicolon. 57

57

Save that, now let's go into our buttons and assign that straight away. 58

58

So find Button > Background > cactus. 59

59

Now the Cactus has a defender prefab, let's click on that there and 60

60

we will assign cactus and then trophy and we will assign trophy, there we go. 61

61

Okay, so 62

62

we've linked the button to the particular prefab that we have in our folder. 63

63

Okay, so save that, that's all looking pretty good, what next? 64

64

Well, let's jump over to the DefenderSpawner script, and 65

65

see what's going on in here. 66

66

First of all, we've got this notion of, previously, 67

67

we didn't have a Defender type, so we're calling things GameObject. 68

68

Let's go and change that, so 69

69

that they're all Defender where we're referring to defender. 70

70

So this will be defender defender and 71

71

also we don't need the serialized field anymore on the DefenderSpawner 72

72

because that is being determined by what is being clicked on on the buttons. 73

73

So we're not gonna let the designer go and monkey around that. 74

74

We'll get rid of the serialized field. 75

75

It's just now defender defender, where else is that gonna be relevant? 76

76

Well, let's see where defender is being called. 77

77

And you see we've got the red squiggly line down here, 78

78

it's saying I'm not a game object anymore, I am a defender. 79

79

So defender instantiate, 80

80

[SOUND] as defender much more specific than just saying GameObject. 81

81

Okay, it looks pretty good and 82

82

I think we're referring to game object anywhere else, good. 83

83

Next we need a way of creating a public method within the DefenderSpawner, 84

84

we say this is who should be selected. 85

85

And then within the DefenderButton, we could then say hey, 86

86

I will to select my particular defender at the thing you should spawn. 87

87

So start with the public method in, DefenderSpawner. 88

88

So I'll say public void SetSelectedDefender and 89

89

then we need to pass in of type Defender. 90

90

And we'll call this defenderToSelect. 91

91

That's the one that somewhere else is saying, hey select me and 92

92

then we have our parentheses. 93

93

Now what I'd like for you to do in here is to just finish off as a little challenge. 94

94

Finish off to assign the passed in defender as the current defender. 95

95

So we're pasing in this defenderToSelect, which will be called in DefenderButton. 96

96

We'll say, okay, give us the defender and then we want to assign that to 97

97

the current defender, so pretty simple just two words and one equal sign. 98

98

There's a big hint for you, so just finish that for me now if you will. 99

99

Okay, straightforward so 100

100

defender = defenderToSelect. 101

101

So, the thing that's getting passed in is now being assigned to defender and 102

102

we'll save that. 103

103

Last step in this process, back to DefenderButton. 104

104

We need somewhere in here that we say, okay, 105

105

I would now like to tell everybody who to spawn. 106

106

Who is the selected defender. 107

107

So on the OnMouseDown method right there the very bottom, 108

108

underneath GetComponentSpriteRenderer where we're changing the color to white, 109

109

we're gonna be calling our SetSelectedDefender. 110

110

So first of all we need to FindObjectOfType and the type is what? 111

111

It is DefenderSpawner. 112

112

That's where we've created our public method .SetSelectedDefender. 113

113

Now, we need to pass something in, what are we gonna pass in from here? 114

114

Well, pretty straightforward, we're gonna pass in the defenderPrefab. 115

115

So we know who the defenderPrefab is, if this is on the cactus, 116

116

the defenderPrefab is the cactus. 117

117

So defenderPrefab in here, excellent! 118

118

When that's called that will pass it in, so we know what to spawn. 119

119

Now save everything up, if that's all gone to plan when we click on Play, 120

120

we should be able to select the cactus which has been what we've spawning up 121

121

until now, works, and the trophy, and it works! 122

122

Nice and lovely, now one thing you might have noticed is the trophy 123

123

looks a little bit weird, a little bit strange, it's not in the right spot. 124

124

So let's fix that, first of all, now click on trophy, 125

125

my one trophy that I've got in my world here, have a look at it. 126

126

Okay, it looks like when we place it, there's a bit of an offset, so if I have 127

127

this at exactly four and four, you can see that it's a little bit too high. 128

128

So our child object a little bit too high. 129

129

Now, here's a really interesting thing, 130

130

really interesting problem that we can create for ourselves with animation 131

131

is that when I click on base, I can move the base up and down, no problem. 132

132

I can move it right down and 133

133

say yeah that's exactly where I want the base of my trophy to be. 134

134

Now if I click on the top and 135

135

move it down, yeah that's exactly where I want it to be. 136

136

Watch what happens when I click play. 137

137

The top of the trophy's gone back up again. 138

138

So to make that even clearer, if I was to drag that way, way, way, way, 139

139

way down here, and I've clicked on the top. 140

140

I select the trophy bounce animation in the animation window. 141

141

And scroll through that see it immediately goes blink run up here already, 142

142

[SOUND] straight away because the rotation we've got in here is relative 143

143

to the bases itself. 144

144

It's not saying go to a particular coordinates, so you look at the base you 145

145

can drill into it here so we've got rotation, rotation is saying rotate. 146

146

So not saying anything about where to be on the screen. 147

147

However, the position that we've got off the top is saying on the very first frame 148

148

I want you to be whatever this is, 0.48. 149

149

And as we scroll through it's saying I want you now to be at 0.6788. 150

150

So, what do we do about that? 151

151

How can we move this once we've created our positional animation. 152

152

Well, there's a little technique that took me forever to find while I was trying to 153

153

debug this for you. 154

154

If you click on Curves while we've got your position selected 155

155

to the left here, see how there's this white line? 156

156

If you drag that, that will allow you to drag every single one of your key frames 157

157

up or down on that particular parameter or that particular axis. 158

158

So at the moment, we're exchanging the y position. 159

159

If I was to click on x, then it would move it left and right. 160

160

So super handy to know, so 161

161

let's find where we want our animation to be starting. 162

162

Just there, if we scrub through it goes up and then down. 163

163

Okay, it still looks like it's going a bit too high. 164

164

Basically, I don't want it overlapping the top square cuz then we'll get weird 165

165

overlapping issues that we don't really wanna deal with at the moment. 166

166

So let's drag the whole thing down and a little bit to there, bang, and bang. 167

167

Yeah, it looks pretty good. 168

168

Could probably make this whole star a little bit smaller, 169

169

so I can do that naturally. 170

170

I don't have to do that with animate that with a key frame. 171

171

I'll just click on my Scale tool, make it a little bit smaller, and 172

172

now it will retain that, yeah, that's cool. 173

173

Cuz it's changing the position, that's what's being animated, okay, 174

174

up to the top there. 175

175

And maybe I'll, how's that look everyone? 176

176

Let's see, just have a little look see at that, make sure it looks okay, 177

177

we don't want the star now to be, yeah, and bam. 178

178

Okay, yeah, I'm pretty happy with that. 179

179

Okay, so click on Trophy, apply that to the prefab. 180

180

As a final tweak I'm gonna bring it up a tiny bit bigger. 181

181

Yeah, so it looks a little bit more natural. 182

182

I want it to look like it's slamming down, slam slam. 183

183

Okay, good, all done, excellent, okay, great stuff. 184

184

So we can now place our defenders, we can choose the defender and place them. 185

185

Next up we need to start our resource system so 186

186

that our defenders cost points, and that we can start seeing whether 187

187

you have enough points to place these things down or not. 188

188

So great stuff, 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.