All language subtitles for lesson096

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
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 Download
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
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:06,656 --> 00:00:12,544 Creating an actual inventory system is 2 00:00:12,800 --> 00:00:16,384 Cattle are more challenging than just creating coins and health 3 00:00:16,896 --> 00:00:23,040 An inventory system might allow us to collect keys and maybe various objects for fish 4 00:00:23,296 --> 00:00:26,624 Quests that we can add to a inventory 5 00:00:26,880 --> 00:00:33,024 So what I want to do is first and foremost let you guys know the inventory systems or very.com 6 00:00:33,280 --> 00:00:34,304 In most games 7 00:00:34,816 --> 00:00:40,960 How to create a very simplistic inventory system here which was show a collected item so let's say 8 00:00:41,216 --> 00:00:41,728 Key 9 00:00:41,984 --> 00:00:44,544 It's a pop-up in the right-hand corner over here 10 00:00:45,312 --> 00:00:47,616 And if we use a key it's going to disappear 11 00:00:48,128 --> 00:00:51,200 And also guys for the purposes of this course 12 00:00:51,456 --> 00:00:56,576 I'm going to only allow for one inventory item being held at a time 13 00:00:56,832 --> 00:01:01,549 I know that sounds like it's very limiting by believe it or not even never song my recent release on switch 14 00:01:01,551 --> 00:01:03,899 Subtitled by -♪ online-courses.club ♪- We compress knowledge for you! https://t.me/joinchat/ailxpXoW3JVjYzQ1 15 00:01:03,900 --> 00:01:05,280 PlayStation apple Arcade 16 00:01:05,536 --> 00:01:09,120 Only allows for one inventory item being held at a time 17 00:01:09,632 --> 00:01:12,704 So how exactly are we gonna start doing this 18 00:01:13,216 --> 00:01:17,568 What the very least I know that I want to create some inventory item indicators 19 00:01:17,824 --> 00:01:20,384 Does jump into rui and double click it 20 00:01:21,408 --> 00:01:24,992 I know I need a slot that shows up that's blank 21 00:01:25,760 --> 00:01:27,296 I just got a new layer 22 00:01:28,320 --> 00:01:29,600 Select the 23 00:01:29,856 --> 00:01:33,440 Ellipse tool here so click and holding make sure it's all selected 24 00:01:34,976 --> 00:01:38,048 Ian let's go ahead and create a lips here 25 00:01:38,560 --> 00:01:44,704 Now you never said a squash I can make all sorts of shapes year old shifts so it's a uniform circle 26 00:01:44,960 --> 00:01:47,520 I'm really create about right 27 00:01:47,776 --> 00:01:50,592 To make sure that is filled with white 28 00:01:51,104 --> 00:01:53,408 And make sure the stroke is 9 29 00:01:54,688 --> 00:02:00,832 Just be sure you select your Move to when you are moving around and if you guys are struggling to see 30 00:02:01,088 --> 00:02:02,624 Is transformed controls 31 00:02:03,136 --> 00:02:04,672 Resume and you can see it better 32 00:02:05,184 --> 00:02:07,232 Rotating or scaling 33 00:02:07,488 --> 00:02:08,768 Simply because 34 00:02:09,280 --> 00:02:12,096 You need to make sure that when you've selected the move tour 35 00:02:12,352 --> 00:02:14,656 Show transform controls is ticked 36 00:02:14,912 --> 00:02:15,424 True 37 00:02:16,448 --> 00:02:17,472 And where 38 00:02:17,728 --> 00:02:19,264 Is also selected 39 00:02:20,288 --> 00:02:22,592 No it for some reason you've deselected 40 00:02:23,104 --> 00:02:24,384 Your circle here 41 00:02:24,640 --> 00:02:26,176 If you have parcel acted 42 00:02:26,688 --> 00:02:30,784 If you want to select the circle you can either select the layer here or 43 00:02:31,296 --> 00:02:32,064 Select 44 00:02:32,576 --> 00:02:35,136 Remove door and press ctrl and click 45 00:02:36,160 --> 00:02:37,952 And now we can move it over here 46 00:02:38,208 --> 00:02:39,744 This is going to be our 47 00:02:40,000 --> 00:02:42,304 What's 3 name it inventory 48 00:02:43,584 --> 00:02:44,096 Link 49 00:02:44,864 --> 00:02:46,912 My sister blank slot right 50 00:02:47,168 --> 00:02:48,960 Does jump back in the Unity 51 00:02:49,216 --> 00:02:49,984 Input there 52 00:02:50,240 --> 00:02:51,264 Rui 53 00:02:51,776 --> 00:02:52,544 In the canvas 54 00:02:53,056 --> 00:02:54,336 Import 55 00:02:54,848 --> 00:02:59,968 Selecta you I in actually got a spray editor you just make sure it's showing up 56 00:03:00,224 --> 00:03:01,504 Let's go to our 57 00:03:01,760 --> 00:03:04,320 Black back on here by clicking this button is going to show us 58 00:03:04,576 --> 00:03:05,344 Ok 59 00:03:05,856 --> 00:03:12,000 Give us a better idea of where it actually is so it's like I got moved all the way down here so there is our inventory 60 00:03:12,256 --> 00:03:13,536 That looks great 61 00:03:14,048 --> 00:03:17,376 So let's go ahead in bring this into a UI canvas 62 00:03:17,632 --> 00:03:20,448 Talking to do as well just to create a new game object 63 00:03:20,960 --> 00:03:21,728 UI 64 00:03:22,240 --> 00:03:22,752 Image 65 00:03:25,312 --> 00:03:31,456 Ok it looks really big but it actually really small on the game view 66 00:03:32,480 --> 00:03:34,272 How much is dragon armour here 67 00:03:34,784 --> 00:03:35,808 Guys remember 68 00:03:36,064 --> 00:03:37,856 How to set the Anchor Presets 69 00:03:38,368 --> 00:03:39,136 To the top right 70 00:03:40,160 --> 00:03:41,440 Perfect hairy girl 71 00:03:41,696 --> 00:03:47,584 Just because I want us to be perfectly in line I'm in a drag this over all the way over here is zoom in some close 72 00:03:48,352 --> 00:03:54,496 Looks like you're about three-and-a-half 3 and a quarter for three three and 3 quarters Square 73 00:03:54,752 --> 00:03:56,032 Where is grade units 74 00:03:56,288 --> 00:03:57,824 Away from the left 75 00:03:58,080 --> 00:03:59,360 Side of a canvas so 76 00:03:59,616 --> 00:04:01,152 If we just drag over to the right 77 00:04:01,920 --> 00:04:04,992 News similar principles so 3 78 00:04:05,504 --> 00:04:06,528 27/5 79 00:04:06,784 --> 00:04:08,064 Units from the right 80 00:04:08,832 --> 00:04:13,696 That's fine and take to be too picky here so we got a square here 81 00:04:14,464 --> 00:04:20,095 Now let's go ahead and drag that inventory blank into the spray field 82 00:04:21,631 --> 00:04:23,935 Here we go and then just let me decide 83 00:04:24,703 --> 00:04:25,471 Alright 84 00:04:25,727 --> 00:04:29,055 So now we have an inventory blank so it's just a little circle here 85 00:04:29,823 --> 00:04:30,847 And 86 00:04:31,103 --> 00:04:35,199 Little Miss alive now that we've said the size Drake there we go 87 00:04:35,711 --> 00:04:36,991 Alright so 88 00:04:37,247 --> 00:04:39,551 Is dragon animal 89 00:04:40,063 --> 00:04:41,855 I must be sure to rename this 90 00:04:42,623 --> 00:04:43,391 Inventory 91 00:04:44,159 --> 00:04:44,927 Adam 92 00:04:45,695 --> 00:04:47,487 So basically what we're gonna do here 93 00:04:47,999 --> 00:04:49,791 Is when we collect a key 94 00:04:50,047 --> 00:04:51,839 When it's added to your inventory 95 00:04:52,863 --> 00:04:55,167 We're going to add it to the inventory 96 00:04:55,423 --> 00:04:56,447 Via script 97 00:04:56,703 --> 00:04:59,775 Also going to indicate that we have that item 98 00:05:00,031 --> 00:05:03,359 Am I going to replace this blank sprite 99 00:05:03,615 --> 00:05:04,127 With 100 00:05:04,383 --> 00:05:05,407 80 sprite 101 00:05:05,663 --> 00:05:06,431 Example 102 00:05:07,199 --> 00:05:10,015 Tesco heading Creed that he spray really quickly 103 00:05:10,527 --> 00:05:15,647 But jump back into Photoshop nearly there click on Photoshop or you can just double click on 104 00:05:15,903 --> 00:05:17,439 UI for a shop aisle 105 00:05:17,951 --> 00:05:20,255 So we have a blank inventory item 106 00:05:20,511 --> 00:05:22,047 Just got him create a key 107 00:05:22,559 --> 00:05:25,631 Now we're going to get into actually doing artwork 108 00:05:25,887 --> 00:05:29,983 In a Later series sofa now which is going to Google 109 00:05:31,263 --> 00:05:37,407 Google Keep yng I would like this one so let's just right click on it say there's 110 00:05:37,663 --> 00:05:38,431 NN 111 00:05:38,687 --> 00:05:40,223 Save it in a download file 112 00:05:40,991 --> 00:05:44,063 All I do is just click on it it opens right up in Photoshop 113 00:05:44,831 --> 00:05:47,135 If it doesn't open up in Photoshop on a medically 114 00:05:47,391 --> 00:05:51,743 Just be sure you go to your downloads folder here right click go to open with 115 00:05:52,767 --> 00:05:58,911 Nazi Photoshop you can choose another app and actually you should probably do it this way anyway choose another 116 00:05:59,167 --> 00:06:02,751 What's the time for the shop in the news always use this app to open png files 117 00:06:03,263 --> 00:06:04,799 How to make things a lot easier for you 118 00:06:05,567 --> 00:06:09,151 Once it's opened up in Photoshop I'm just gonna press control a 119 00:06:09,919 --> 00:06:12,479 Select this entire 120 00:06:12,991 --> 00:06:16,575 P&g care and control see that's just edit copy right 121 00:06:18,111 --> 00:06:22,463 Going to my UI file here in control via that's just pay store 122 00:06:22,719 --> 00:06:23,231 Pace 123 00:06:24,511 --> 00:06:28,351 Ragged on over here now if you don't see any controls 124 00:06:28,607 --> 00:06:29,631 Taxi scale 125 00:06:31,423 --> 00:06:32,959 Because when you have 126 00:06:33,215 --> 00:06:34,751 The move tool selected here 127 00:06:35,007 --> 00:06:38,079 Show transform controls is not ticked to true 128 00:06:38,591 --> 00:06:41,663 I want to make sure that the layer is selected here 129 00:06:42,175 --> 00:06:43,711 That allows me to actually 130 00:06:44,223 --> 00:06:45,247 Click on this 131 00:06:45,503 --> 00:06:46,271 Any more 132 00:06:46,783 --> 00:06:47,551 Suck my life 133 00:06:48,319 --> 00:06:51,647 The way that I select a layer is I hope control 134 00:06:52,415 --> 00:06:53,695 And then now I can click 135 00:06:54,463 --> 00:06:56,255 So you want to select something 136 00:06:56,511 --> 00:06:57,279 When you're using 137 00:06:57,535 --> 00:06:58,559 The move tool 138 00:06:59,071 --> 00:07:00,095 Control 139 00:07:00,351 --> 00:07:02,143 All sorts of stuff 140 00:07:02,399 --> 00:07:03,679 Torquay 141 00:07:03,935 --> 00:07:08,031 The transform box is showing up so we can scale it down just a little bit 142 00:07:08,543 --> 00:07:09,311 In the present 143 00:07:09,823 --> 00:07:11,871 Now it's been Transformed 144 00:07:12,127 --> 00:07:13,151 To a smaller size 145 00:07:13,663 --> 00:07:15,711 I'm going to put it I'll have a bit centre here 146 00:07:16,479 --> 00:07:17,759 Shift 147 00:07:18,015 --> 00:07:23,391 Just tried to the 11 I cannot allow us to actually drag along the x-axis in Photoshop 148 00:07:24,159 --> 00:07:26,975 Last thing we want to do image adjustments invert 149 00:07:27,231 --> 00:07:29,023 Invert from Black 150 00:07:31,583 --> 00:07:33,631 Be sure you name it inventory 151 00:07:33,887 --> 00:07:34,399 Key 152 00:07:34,655 --> 00:07:39,263 Remember guys I like to name things with the broader category as the first word 153 00:07:39,775 --> 00:07:41,567 Any more specific category 154 00:07:41,823 --> 00:07:42,591 At last 155 00:07:43,103 --> 00:07:45,663 So it's a broad category of inventory 156 00:07:46,175 --> 00:07:49,503 Any more specific category of key or blank 157 00:07:49,759 --> 00:07:53,087 Or maybe you get a flamethrower or maybe you get 158 00:07:53,343 --> 00:07:54,879 And I Know It trophy 159 00:07:55,647 --> 00:07:57,439 You slowly get more specific 160 00:07:57,695 --> 00:08:00,511 As you go down a line of words to the right so 161 00:08:00,767 --> 00:08:02,559 Generic then specific 162 00:08:03,583 --> 00:08:04,351 Alright 163 00:08:04,607 --> 00:08:05,375 Save 164 00:08:06,143 --> 00:08:07,679 When is John back in the Unity 165 00:08:10,239 --> 00:08:11,263 The import 166 00:08:12,287 --> 00:08:13,055 Awesome 167 00:08:13,311 --> 00:08:16,127 And as you can see we now have an inventory key 168 00:08:16,895 --> 00:08:18,175 An inventory blank 169 00:08:18,687 --> 00:08:20,991 So you may notice something here 170 00:08:21,503 --> 00:08:24,063 We're going to the you I hear you got a Sprite editor 171 00:08:24,575 --> 00:08:30,719 We turn the background black just for the purposes of looking around in zoom in and then click the middle Mouse button to drag 172 00:08:30,975 --> 00:08:33,791 You noticed that the key is much bigger 173 00:08:34,559 --> 00:08:35,839 In the inventory blank 174 00:08:36,351 --> 00:08:37,887 So what that means is 175 00:08:38,143 --> 00:08:40,447 If I swap out this inventory item 176 00:08:40,703 --> 00:08:41,727 With the key 177 00:08:43,519 --> 00:08:45,567 She is really small 178 00:08:46,079 --> 00:08:49,151 How can a we're being wanted to be Dad 179 00:08:49,407 --> 00:08:51,199 How do we solve this 180 00:08:51,455 --> 00:08:53,247 Just going to Photoshop you 181 00:08:54,271 --> 00:08:57,343 And this is actually a really simple trick that you can do 182 00:08:58,111 --> 00:08:59,135 Resume in 183 00:08:59,391 --> 00:09:00,159 And that's with 184 00:09:00,415 --> 00:09:06,559 Prezi and then ensure that scrubby zoom is turned off I really don't like scrubby zoom if you want to use that 185 00:09:06,815 --> 00:09:08,863 But I turn off family room in the night 186 00:09:09,887 --> 00:09:10,655 Zoom in here 187 00:09:11,167 --> 00:09:11,935 Prestige 188 00:09:12,959 --> 00:09:14,751 I can see that this size 189 00:09:15,263 --> 00:09:16,799 Is a little bit bigger 190 00:09:17,055 --> 00:09:17,823 And this one 191 00:09:18,335 --> 00:09:19,871 Press ctrl click on this 192 00:09:20,639 --> 00:09:21,663 See that 193 00:09:22,687 --> 00:09:24,735 It's about 100 pixels 194 00:09:25,247 --> 00:09:29,343 That bloke all out there showing the size there about 100 pixels 195 00:09:29,599 --> 00:09:30,879 100 pixels 196 00:09:31,903 --> 00:09:38,047 So let's go ahead in try and make this 100 pixels by 100 pixels 197 00:09:38,303 --> 00:09:42,911 Even being 100 pixels by 100 pixels it'll make sense in just a second 198 00:09:43,679 --> 00:09:47,007 So we have this inventory blank layer selected 199 00:09:47,263 --> 00:09:49,567 You can duplicate it by going to right click 200 00:09:52,127 --> 00:09:54,943 How much is name this inventory blank 201 00:09:57,503 --> 00:10:00,319 This not really matter just me so it's just presenter here 202 00:10:00,345 --> 00:10:02,504 Subtitled by -♪ online-courses.club ♪- We compress knowledge for you! https://t.me/joinchat/ailxpXoW3JVjYzQ1 203 00:10:02,505 --> 00:10:02,879 And now we can actually scale this up 204 00:10:05,695 --> 00:10:07,743 That big here double click 205 00:10:07,999 --> 00:10:09,023 Or press enter 206 00:10:09,791 --> 00:10:11,839 And now the transform has been confirmed 207 00:10:12,351 --> 00:10:15,167 In luck we can change the opacity of this layer 208 00:10:15,679 --> 00:10:18,239 Bring it down to 5% 209 00:10:18,751 --> 00:10:21,823 Now it looks like it might be a little bit bigger 210 00:10:22,335 --> 00:10:23,359 Dennis key 211 00:10:23,615 --> 00:10:26,431 How we know they were hitting the exact size of this key 212 00:10:26,943 --> 00:10:28,735 Why should go to view 213 00:10:28,991 --> 00:10:30,527 And they make sure your rollers 214 00:10:30,783 --> 00:10:32,063 Is ticked to true 215 00:10:32,319 --> 00:10:34,623 And all that means it's going to show these rulers here 216 00:10:35,135 --> 00:10:37,951 The cool thing you can do it is rollers actually create guides 217 00:10:38,207 --> 00:10:40,511 But you want to make sure that those guys actually show up 218 00:10:40,767 --> 00:10:41,791 So when you got a view 219 00:10:42,303 --> 00:10:43,071 Show 220 00:10:43,583 --> 00:10:45,631 Make sure guides is turned on 221 00:10:45,887 --> 00:10:47,935 Drag these guides down 222 00:10:48,703 --> 00:10:51,007 It looks like the top is about right here 223 00:10:51,775 --> 00:10:53,567 And I will do another one drag down 224 00:10:54,335 --> 00:10:55,871 There's the bottom ok 225 00:10:56,383 --> 00:10:57,407 Looks like 226 00:10:58,687 --> 00:11:01,503 This needs to be moved down a little bit 227 00:11:01,759 --> 00:11:03,295 Let's make a little bit brighter 228 00:11:03,551 --> 00:11:04,575 We can see area 229 00:11:05,087 --> 00:11:07,647 I like both of these holding shift 230 00:11:07,903 --> 00:11:09,695 Excited both layers 231 00:11:10,463 --> 00:11:13,535 And now I can actually just scale it down and move it down 232 00:11:14,047 --> 00:11:15,071 As one unit 233 00:11:16,607 --> 00:11:17,375 Here we go 234 00:11:17,631 --> 00:11:20,191 Know if this was maybe over here like that 235 00:11:20,447 --> 00:11:23,519 If you select both layers you can actually just sent to them up 236 00:11:24,287 --> 00:11:26,847 Using is a line tortilla so that's the vertical one 237 00:11:27,103 --> 00:11:28,383 When is the horizontal 238 00:11:29,151 --> 00:11:32,223 But now it looks like it's exactly the size of the key 239 00:11:32,735 --> 00:11:34,527 And I really like that Alex great 240 00:11:35,039 --> 00:11:35,807 So 241 00:11:36,063 --> 00:11:41,439 One of the ways we could get this to work is simply just convert this to a smart object 242 00:11:42,463 --> 00:11:48,607 And that basically put everything into one file so I can double click on this if I want to change 243 00:11:48,863 --> 00:11:51,423 Things so for example if I wanted to make a 244 00:11:51,679 --> 00:11:53,471 Can I make this right or something 245 00:11:54,239 --> 00:11:55,519 Just save that 246 00:11:55,775 --> 00:11:57,567 Go back into my UI file 247 00:11:57,823 --> 00:11:59,103 Can you see it updated 248 00:11:59,615 --> 00:12:05,759 Basically when you create a smart object create a Photoshop file inside of a Photoshop file you only just 249 00:12:06,015 --> 00:12:12,159 How unity sees this there because the moment you import this into unity or just updated inside of you 250 00:12:12,415 --> 00:12:17,535 It's not going to see another Photoshop file it is going to go all that's another png layer 251 00:12:18,047 --> 00:12:19,327 Don't worry too much about that 252 00:12:20,095 --> 00:12:21,375 So we do it that way 253 00:12:21,631 --> 00:12:23,423 And now we have one image here 254 00:12:23,935 --> 00:12:26,751 And us go back into that so just double click and 255 00:12:27,263 --> 00:12:28,543 Let's make it white again 256 00:12:29,055 --> 00:12:30,079 And save it out 257 00:12:30,335 --> 00:12:32,895 And it looks like we're going to go 258 00:12:33,151 --> 00:12:34,687 Don't forget to rename you later 259 00:12:34,943 --> 00:12:36,991 Tell us to inventory 260 00:12:38,783 --> 00:12:42,367 Unity remember that this is the blank inventory item 261 00:12:43,903 --> 00:12:50,047 Go back to where you are I and go to the import settings and then Sprite editor and take a look when we can collect this 262 00:12:50,815 --> 00:12:53,887 Ok great so now we have a black background 263 00:12:54,399 --> 00:13:00,543 It looks like we're getting close we want this to be the exact same size so that when we swap them out 264 00:13:00,799 --> 00:13:01,567 You collect the key 265 00:13:02,079 --> 00:13:03,103 The sizes match 266 00:13:03,871 --> 00:13:06,175 What looks like this one is 103 by 1 and 3 267 00:13:06,431 --> 00:13:09,759 That number how about 105 by 105 268 00:13:10,015 --> 00:13:13,599 Again guys what were changing here is not the size of the p&g 269 00:13:13,855 --> 00:13:16,415 Where does changing the size of the cut out 270 00:13:16,671 --> 00:13:17,695 Other png 271 00:13:18,207 --> 00:13:24,351 This is literally looking over transparency with these printed Sprites on it and you literally with an exam 272 00:13:24,607 --> 00:13:27,423 Cutting out the Sprite ok 273 00:13:28,447 --> 00:13:32,031 So this one here was just thinking the same thing 105 274 00:13:33,311 --> 00:13:34,591 Bye 105 275 00:13:35,103 --> 00:13:35,871 We go 276 00:13:36,383 --> 00:13:39,711 Does the inventory key and this is the inventory blank 277 00:13:39,967 --> 00:13:41,503 Reply 278 00:13:42,527 --> 00:13:45,343 Alright and then xlove are spray editor 279 00:13:46,111 --> 00:13:48,927 And you're still no it's small and that's ok 280 00:13:49,439 --> 00:13:51,231 Manchester concert need a size here 281 00:13:52,255 --> 00:13:52,767 Awesome 282 00:13:53,023 --> 00:13:57,887 So what happens that say if I use the spiky that's tested out 283 00:13:58,399 --> 00:13:59,935 I use the spiky 284 00:14:00,447 --> 00:14:01,983 Script that will say 285 00:14:02,239 --> 00:14:04,543 Swap it back to inventory blank 286 00:14:05,823 --> 00:14:11,967 Sweet turn out a blank inventory item some of you might be thinking Thomas that kind of looks like an item it doesn't 287 00:14:12,223 --> 00:14:16,575 A blank slate what would you do is actually just jump back in the photo shop 288 00:14:17,343 --> 00:14:23,231 Open up that smart object for the inventory blank Sprite that is double click on this layer 289 00:14:24,511 --> 00:14:28,351 This bigger circle to something like 1% 290 00:14:29,119 --> 00:14:30,399 If you make it 0 291 00:14:30,655 --> 00:14:33,471 You know these girls can I get confused and shrink down 292 00:14:33,727 --> 00:14:35,263 That's sliced size 293 00:14:36,031 --> 00:14:42,175 Remember we didn't actually save the UI file we only save the smart object so make sure when you say this 294 00:14:42,431 --> 00:14:45,759 Project with ctrl S jump back into your new wife I'll 295 00:14:46,271 --> 00:14:47,295 And then it save again 296 00:14:48,063 --> 00:14:52,415 So we're going uni here it's going to automatically update this 297 00:14:52,927 --> 00:14:54,719 You can't even see that circle 298 00:14:54,975 --> 00:14:57,279 It's still exist you can barely see it 299 00:14:58,303 --> 00:15:00,607 But I think for the purposes of this tutorial 300 00:15:00,863 --> 00:15:01,631 That looks great 301 00:15:02,399 --> 00:15:05,215 Against the reason why we added this faint circle 302 00:15:05,471 --> 00:15:07,519 It's so that when we go to the spray editor 303 00:15:09,567 --> 00:15:10,847 Internet background black 304 00:15:11,615 --> 00:15:14,431 It doesn't put these up really snug with each other 305 00:15:14,943 --> 00:15:16,479 Allows us to create 306 00:15:16,735 --> 00:15:18,783 Same size for both of them 307 00:15:19,039 --> 00:15:23,647 So that we can swap them out with scripts and you're not going to get weird scaling issues 308 00:15:24,415 --> 00:15:25,183 Ok 309 00:15:25,439 --> 00:15:28,255 So we have a blink inventory slot 310 00:15:28,767 --> 00:15:30,303 That will be swap down 311 00:15:30,815 --> 00:15:32,607 When you collect a key for example 312 00:15:33,119 --> 00:15:34,655 With the inventory key 313 00:15:34,911 --> 00:15:35,423 Sprite 314 00:15:35,679 --> 00:15:38,495 I just collected achy right that's how it's supposed to look 315 00:15:39,007 --> 00:15:44,639 Alright let's do one last thing here let's just double check and make sure everything looks good and various sizes 316 00:15:47,199 --> 00:15:49,503 Can I suggest you guys double check as well 317 00:15:51,039 --> 00:15:52,063 Sweet looks awesome 318 00:15:52,575 --> 00:15:58,719 Everything was good at various sizes no matter where were playing this game whether it's on your Xbox PlayStation 319 00:15:58,975 --> 00:16:01,535 Apple devices anything is going to look great 320 00:16:01,791 --> 00:16:06,911 In the next section we can talk about coding this inventory system and swapping up that key 321 00:16:07,679 --> 00:16:13,823 So this is where the fun begins now that we have the UI for the inventory 322 00:16:14,079 --> 00:16:16,127 We can collect so for example a key 323 00:16:16,639 --> 00:16:22,783 I need actually write some script that will throw the key on the screen and also script something that place is that 324 00:16:23,039 --> 00:16:24,831 Into some kind of variable 325 00:16:25,343 --> 00:16:27,903 So instead of creating a whole new script 326 00:16:28,415 --> 00:16:29,951 For our inventory 327 00:16:30,463 --> 00:16:34,559 Because we're going to keep things clean and simple we're going to put it inside of the player screw 328 00:16:34,815 --> 00:16:37,119 I told you guys will be using the player script a lot 329 00:16:37,375 --> 00:16:38,655 Set up new player 330 00:16:40,703 --> 00:16:43,775 And working I create a new variable type 331 00:16:44,031 --> 00:16:44,543 Call 332 00:16:44,799 --> 00:16:45,567 Dictionary 333 00:16:46,591 --> 00:16:47,103 Now 334 00:16:47,871 --> 00:16:51,711 It's not like an integer it's not a float it's not bullying 335 00:16:52,479 --> 00:16:58,623 It's not a vector to it's not about 3 it's a totally different type of variable and it's a really cold 336 00:16:58,879 --> 00:17:01,695 Because they can store values inside of it 337 00:17:01,951 --> 00:17:05,791 So let's just write it out in don't panic it's going to look weird 338 00:17:06,047 --> 00:17:12,191 But it all makes sense to you eventually I just trust me guys just keep practising 339 00:17:13,471 --> 00:17:14,751 Where to take the public 340 00:17:15,519 --> 00:17:16,543 Dictionary 341 00:17:17,311 --> 00:17:19,359 Ok like a dirty telling us how to write this 342 00:17:19,615 --> 00:17:22,431 Ok so can I use these less than 343 00:17:22,687 --> 00:17:23,967 Integrated hand signs 344 00:17:24,223 --> 00:17:26,527 So what we do here is type string 345 00:17:27,807 --> 00:17:29,087 And then sprite 346 00:17:29,343 --> 00:17:35,487 What the heck Tom is what is this mean well first of guys I wanted to be on 347 00:17:35,743 --> 00:17:37,023 I'm looking 348 00:17:37,535 --> 00:17:39,839 Add unity documentation right now 349 00:17:40,095 --> 00:17:40,863 Ok 350 00:17:41,119 --> 00:17:42,655 I don't memorise this 351 00:17:42,911 --> 00:17:44,959 It's okay to not memorise 352 00:17:45,215 --> 00:17:48,031 Complex variable forms like this 353 00:17:48,799 --> 00:17:50,335 So it's ok love things up 354 00:17:50,591 --> 00:17:53,407 Basically what this means is were going to store 355 00:17:53,663 --> 00:17:54,431 A string 356 00:17:54,687 --> 00:17:56,223 M a sprite 357 00:17:56,991 --> 00:17:58,271 Inside of this dictionary 358 00:17:58,783 --> 00:18:03,391 Ok dictionary as being able to say that one 359 00:18:04,671 --> 00:18:06,719 Of the dictionary is going to be 360 00:18:07,231 --> 00:18:08,255 Let's see 361 00:18:08,511 --> 00:18:09,791 Gym 362 00:18:10,559 --> 00:18:11,327 Along with 363 00:18:12,095 --> 00:18:13,375 C1 sprite 364 00:18:14,911 --> 00:18:17,215 That's basically what this dictionary is going to allow for 365 00:18:17,727 --> 00:18:23,871 And technically we could do a tonne of sloths here we could add a ton of inventory items 366 00:18:24,127 --> 00:18:25,919 We can have slight too 367 00:18:26,431 --> 00:18:27,455 Is there any equal 368 00:18:28,223 --> 00:18:33,343 About gem key in ASDA string 369 00:18:33,599 --> 00:18:34,879 Nng sprite 370 00:18:35,135 --> 00:18:41,279 Jam key spray terrible terrible name 371 00:18:41,535 --> 00:18:47,679 Get the point right so that's what are dictionaries for it's really abstract right now I think in your head right now 372 00:18:47,935 --> 00:18:48,959 Pretty blurry right 373 00:18:49,983 --> 00:18:54,591 It's gonna make sense I promise I just keep going I find I just 374 00:18:54,847 --> 00:19:00,991 Going and keep what is the song Tori sings just keep swimming right just keep swimming 375 00:19:01,247 --> 00:19:07,391 Keep going and it's going to make sense I promise this dictionary 376 00:19:07,647 --> 00:19:09,183 So let's call it inventory 377 00:19:09,951 --> 00:19:11,231 Now what I done yet 378 00:19:11,743 --> 00:19:15,839 This is weird syntax and it's ok to reference unity documentation 379 00:19:16,351 --> 00:19:17,631 Equal 380 00:19:17,887 --> 00:19:19,935 A new dictionary 381 00:19:21,983 --> 00:19:23,263 String spray 382 00:19:23,775 --> 00:19:25,055 There we go 383 00:19:25,567 --> 00:19:26,591 And close out 384 00:19:27,103 --> 00:19:33,247 Again guys this looks weird right I would not be able to memorise this my memorization skills are 385 00:19:33,503 --> 00:19:34,015 Brenda's 386 00:19:34,271 --> 00:19:38,111 It's ok if you don't memorise how to do this 387 00:19:39,135 --> 00:19:41,439 Simply copying and pasting is essentially 388 00:19:41,695 --> 00:19:43,231 Communities documentation 389 00:19:43,487 --> 00:19:45,791 What does matter is I know 390 00:19:46,047 --> 00:19:48,863 That we need to use the variable type dictionary 391 00:19:49,119 --> 00:19:50,655 To store inventory items 392 00:19:51,679 --> 00:19:52,959 So that's the important thing 393 00:19:53,727 --> 00:19:55,519 Get rid of this 394 00:19:55,775 --> 00:19:56,543 David out 395 00:19:57,055 --> 00:19:59,103 And the next thing we want to do 396 00:19:59,871 --> 00:20:00,895 Is wee white 397 00:20:01,151 --> 00:20:02,943 To start to add 398 00:20:03,199 --> 00:20:07,807 Some inventory items and see if it works ok so let's add 399 00:20:08,063 --> 00:20:08,831 The key 400 00:20:09,087 --> 00:20:10,879 Inventory item ok 401 00:20:11,391 --> 00:20:12,671 How will we do this 402 00:20:12,927 --> 00:20:13,951 Well 403 00:20:14,719 --> 00:20:15,743 What's tested 404 00:20:16,255 --> 00:20:21,631 In the start here I like to test things out in the start function just to see if it actually works 405 00:20:21,887 --> 00:20:22,399 Ok 406 00:20:22,911 --> 00:20:29,055 So I know you have a variable called inventory so I can do inventory and then I can do some poo 407 00:20:29,311 --> 00:20:30,079 Functionality 408 00:20:30,335 --> 00:20:32,127 With this dictionary 409 00:20:32,383 --> 00:20:33,407 Variable type 410 00:20:34,175 --> 00:20:36,735 Actually use the word hadn't shown up right there 411 00:20:36,991 --> 00:20:37,759 Ok cool 412 00:20:38,271 --> 00:20:39,807 My apprentices 413 00:20:40,319 --> 00:20:44,671 Ok so I can add a string value yeah there it is and I can also display value 414 00:20:45,439 --> 00:20:47,487 Ok so I can add a key one 415 00:20:47,999 --> 00:20:49,279 Are you comma 416 00:20:49,791 --> 00:20:53,631 And then some Sprite so key sprite 417 00:20:54,911 --> 00:20:56,447 Say that out and 418 00:20:56,703 --> 00:20:57,471 Make sure we 419 00:20:57,727 --> 00:20:59,007 Close it out with semicolon 420 00:20:59,519 --> 00:21:01,823 Why is this red zigzag appearing 421 00:21:02,591 --> 00:21:06,687 The name keys bright does not exist in the current context 422 00:21:07,199 --> 00:21:08,991 Ok so we need to actually create 423 00:21:09,247 --> 00:21:11,551 A Sprite variable appear 424 00:21:12,063 --> 00:21:14,111 Cos it doesn't really know what that is right 425 00:21:14,623 --> 00:21:17,696 Just got hen do that was create a public sprite 426 00:21:18,208 --> 00:21:19,744 He's sprite 427 00:21:20,256 --> 00:21:21,792 We need to do for now 428 00:21:22,560 --> 00:21:24,352 Back in the unity here 429 00:21:25,120 --> 00:21:26,912 Chucky's bride is going to show up 430 00:21:28,192 --> 00:21:28,704 In 431 00:21:28,960 --> 00:21:29,984 A new player 432 00:21:30,240 --> 00:21:31,264 Composer here 433 00:21:32,544 --> 00:21:34,336 Realitatea 434 00:21:34,592 --> 00:21:36,640 So now we can actually have 435 00:21:37,152 --> 00:21:38,432 The inventory key 436 00:21:39,968 --> 00:21:40,480 Ok 437 00:21:40,736 --> 00:21:43,296 Does clear the console save everything 438 00:21:43,552 --> 00:21:44,576 AirPlay 439 00:21:46,624 --> 00:21:47,648 Ok so 440 00:21:47,904 --> 00:21:50,464 Nothing is really happening but 441 00:21:50,720 --> 00:21:51,744 I'm pretty sure 442 00:21:52,512 --> 00:21:54,048 We are Anarchy right 443 00:21:54,304 --> 00:21:57,888 What does debugger to see if it was added to the inventory variable 444 00:21:58,400 --> 00:22:04,544 That inventory variables in a shop anywhere is that going to change or you I currently it's literally just this 445 00:22:05,056 --> 00:22:09,920 Abstract variable floating in the abyss storing information 446 00:22:10,176 --> 00:22:12,224 Is there is this weekend at sea 447 00:22:12,480 --> 00:22:14,272 Flog It and see what we get 448 00:22:14,528 --> 00:22:15,808 Debug.log 449 00:22:16,320 --> 00:22:17,344 How about 450 00:22:17,600 --> 00:22:18,368 Inventory 451 00:22:20,160 --> 00:22:20,928 Is it save 452 00:22:21,952 --> 00:22:22,976 Back in unity 453 00:22:24,768 --> 00:22:25,536 And 454 00:22:25,792 --> 00:22:31,936 Hit play again we get these warnings all the time don't worry about your warnings too much you need to fix them eventually 455 00:22:32,192 --> 00:22:36,032 Let's go down 1920 by 1080 so we can see little bit more here 456 00:22:36,544 --> 00:22:39,616 That is very confusing lochia 457 00:22:39,872 --> 00:22:41,664 Looks like it exists 458 00:22:42,176 --> 00:22:42,944 It says 459 00:22:43,200 --> 00:22:43,712 Dad 460 00:22:44,480 --> 00:22:50,368 Inventory is systems collections generic dictionary with a string in aseprite 461 00:22:50,880 --> 00:22:55,232 In so you can see that it's kind of logging something a little bit abstract 462 00:22:55,744 --> 00:22:57,792 We get a little bit more specific 463 00:22:58,304 --> 00:23:02,912 So it's really telling us what the inventory is which is a dictionary 464 00:23:03,424 --> 00:23:04,448 Variable type 465 00:23:04,704 --> 00:23:06,240 Inventory 466 00:23:06,752 --> 00:23:09,312 And it looks like we can do something like this 467 00:23:09,568 --> 00:23:10,336 England Tory 468 00:23:10,848 --> 00:23:16,992 Mm2 a bracket and a left ok so this is kind of like maybe you can remember matrices or 469 00:23:17,248 --> 00:23:20,832 Arrays in math class is kind of what this is 470 00:23:21,088 --> 00:23:24,160 So we have these brackets here we can actually find 471 00:23:24,416 --> 00:23:26,208 What the spray is 472 00:23:26,720 --> 00:23:32,864 For the string key one so little was looking up I must like when a dictionary lookup 473 00:23:33,376 --> 00:23:35,680 What's the spray associated with keyone 474 00:23:35,936 --> 00:23:36,960 That's pretty cool 475 00:23:37,472 --> 00:23:38,752 Just read it and see what happens 476 00:23:42,080 --> 00:23:42,848 Awesome 477 00:23:43,360 --> 00:23:45,408 Inventory key 478 00:23:46,688 --> 00:23:51,296 Is the Sprite if literally like unit is opening up a dictionary 479 00:23:51,552 --> 00:23:55,904 I'm looking for ok what's the spray associated with T1 480 00:23:57,184 --> 00:23:58,208 Tells us 481 00:23:58,464 --> 00:24:01,536 When we asked it to be logged into the console window 482 00:24:01,792 --> 00:24:02,816 It tells us that it 483 00:24:05,376 --> 00:24:06,144 Is right here 484 00:24:06,400 --> 00:24:07,168 Inventory key 485 00:24:08,192 --> 00:24:09,728 What's Lyca dictionaries working 486 00:24:09,984 --> 00:24:10,752 That's great 487 00:24:11,520 --> 00:24:14,336 It doesn't make sense guys we can keep moving and hopefully 488 00:24:14,592 --> 00:24:19,456 Little Mix it actually promise it's going to make sense because really using this a lot 489 00:24:20,992 --> 00:24:26,368 So just a game a little bit of understanding of how exactly we're going to set this key image 490 00:24:26,880 --> 00:24:29,184 To swap out with this blank images 491 00:24:30,464 --> 00:24:31,488 Just do it 492 00:24:31,744 --> 00:24:33,792 In the start function just a test Adele 493 00:24:34,304 --> 00:24:36,352 So let's go into the start function 494 00:24:36,608 --> 00:24:38,400 Of the new player script here 495 00:24:38,912 --> 00:24:40,960 We've added the inventory right 496 00:24:41,728 --> 00:24:43,776 Denim overalls going to do is we're going to say 497 00:24:44,032 --> 00:24:46,848 That's bright so some pseudocode here 498 00:24:47,616 --> 00:24:49,664 Blank sprite 499 00:24:51,200 --> 00:24:52,480 Should now 500 00:24:53,248 --> 00:24:54,016 Swap 501 00:24:54,528 --> 00:24:55,808 With the keys bright 502 00:24:56,064 --> 00:24:56,576 Ok 503 00:24:58,624 --> 00:25:00,160 How to do this 504 00:25:00,672 --> 00:25:01,440 Well 505 00:25:01,952 --> 00:25:03,744 We need a reference 506 00:25:04,256 --> 00:25:06,048 To that inventory sprite 507 00:25:06,560 --> 00:25:08,608 Torch first create that reference 508 00:25:09,632 --> 00:25:13,984 We're going to go ahead and put it here where to call a public image not a sprite 509 00:25:14,240 --> 00:25:16,032 Again if you go into unity here 510 00:25:16,800 --> 00:25:18,592 Inside the inventory item 511 00:25:18,848 --> 00:25:23,456 Reusing the image component not a Sprite component or the Sprite renderer component 512 00:25:23,968 --> 00:25:25,504 Reason the image 513 00:25:26,272 --> 00:25:29,344 So we need a reference to this so if we go back into our script here 514 00:25:30,112 --> 00:25:31,392 Public image 515 00:25:31,648 --> 00:25:33,184 About inventory 516 00:25:36,000 --> 00:25:37,024 Sounds about right 517 00:25:37,280 --> 00:25:42,912 So what does it allow us to do is actually have a reference to that inventory image 518 00:25:43,680 --> 00:25:49,568 We don't really know what it is we haven't told unity what the inventory image swap even is 519 00:25:50,080 --> 00:25:53,152 So we sleep player you can see inventory images showing up 520 00:25:53,920 --> 00:25:55,712 So we can just drag this 521 00:25:56,224 --> 00:25:56,736 Here 522 00:25:58,016 --> 00:26:01,088 This gameobject is called inventory item 523 00:26:01,344 --> 00:26:07,488 So it may make more sense to me because inventory item image if you get a little bit 524 00:26:07,744 --> 00:26:13,888 Naming your variables is really important to make sure that you're not confusing yourself in the future something kind 525 00:26:14,144 --> 00:26:19,264 Inventory item image is fine so if you actually change the name of a variable 526 00:26:20,288 --> 00:26:25,664 He's going to get confused in lose that reference so just be careful renaming variables 527 00:26:26,176 --> 00:26:28,736 So we can just go and drag inventory item again 528 00:26:29,248 --> 00:26:29,760 So 529 00:26:30,016 --> 00:26:31,296 What is going on here 530 00:26:31,552 --> 00:26:33,344 Well in a new player script 531 00:26:33,600 --> 00:26:35,904 We have a ton of references to a lot of 532 00:26:36,160 --> 00:26:38,976 You know global address going to be using throughout the game 533 00:26:39,232 --> 00:26:41,536 Select inventory out of here 534 00:26:42,048 --> 00:26:45,120 Highlights this and says ok my reference is 535 00:26:45,376 --> 00:26:46,656 This image component 536 00:26:47,168 --> 00:26:49,728 Why do I need to reference the image component 537 00:26:49,984 --> 00:26:53,568 So they can swap out the inventory blank with the inventory key 538 00:26:55,104 --> 00:26:57,152 Right so we have that reference 539 00:26:57,664 --> 00:26:58,688 If we go 540 00:26:59,200 --> 00:27:00,736 Back to the new player script 541 00:27:01,760 --> 00:27:04,320 Weaken below the pseudocode here 542 00:27:04,832 --> 00:27:06,880 In all we Gotta Do Is go 543 00:27:07,392 --> 00:27:08,416 Inventory 544 00:27:10,464 --> 00:27:11,488 Image 545 00:27:11,744 --> 00:27:13,280 That sprite 546 00:27:13,792 --> 00:27:15,072 Equals 547 00:27:16,352 --> 00:27:18,656 We could do key spray if we wanted to 548 00:27:19,168 --> 00:27:22,496 Don't say that and I'll show you how it works so we going to be here 549 00:27:23,264 --> 00:27:25,056 Because this is in the start function 550 00:27:25,568 --> 00:27:26,848 A moment we hit play 551 00:27:27,104 --> 00:27:28,896 It should swap that out with the key 552 00:27:29,152 --> 00:27:29,920 There we go 553 00:27:30,688 --> 00:27:31,200 Ok 554 00:27:31,456 --> 00:27:37,600 Why is that not enough well we need to build 4 scale go for a scale means you're building a system that allows 555 00:27:37,856 --> 00:27:39,648 Functionality in the future 556 00:27:39,904 --> 00:27:42,464 Now we don't want to be so specific here 557 00:27:42,976 --> 00:27:46,560 So what we are rather do here is good want to swap the sprout 558 00:27:46,816 --> 00:27:47,328 With 559 00:27:47,584 --> 00:27:53,728 What the actual string is so that's why using a dictionary because some objects are for example 560 00:27:53,984 --> 00:27:56,544 Trophy is going to have a different sprite 561 00:27:56,800 --> 00:28:00,896 Or maybe a chainsaw is going to have a different sprite 562 00:28:01,152 --> 00:28:05,760 Right so we want to create code that allows for scale in make it reusable 563 00:28:06,016 --> 00:28:09,856 Inventory item image that Sprite is going to equal 564 00:28:10,112 --> 00:28:11,136 Inventory 565 00:28:11,648 --> 00:28:12,672 Remember we can use 566 00:28:13,696 --> 00:28:14,720 Brackets here 567 00:28:15,488 --> 00:28:17,536 And we can type T1 568 00:28:20,096 --> 00:28:23,680 If you can recall when we printed this line of code to the console window 569 00:28:23,936 --> 00:28:24,960 It was out pulling 570 00:28:25,216 --> 00:28:26,752 This the key sprite 571 00:28:27,008 --> 00:28:28,544 Let's save this year 572 00:28:29,568 --> 00:28:30,848 Engine builder unity 573 00:28:32,128 --> 00:28:37,248 So it should perform the same sort of functionality but we're just doing it in a little bit of a different way 574 00:28:37,760 --> 00:28:42,880 Perfect so we have this key Sprite showing up on start that's exactly what we want 575 00:28:43,136 --> 00:28:44,416 Play mode here 576 00:28:44,672 --> 00:28:45,952 Go back into a scrap 577 00:28:47,232 --> 00:28:49,024 So you may be wondering 578 00:28:49,280 --> 00:28:53,632 Why we need to be riding at this way why can't we just reiki sprite 579 00:28:54,144 --> 00:28:57,472 That's because we're going to create a function that allows for us 580 00:28:57,984 --> 00:28:58,496 2 581 00:28:58,752 --> 00:29:02,592 Removing add inventory items over and over again 582 00:29:02,848 --> 00:29:04,640 Without getting too specific 583 00:29:04,896 --> 00:29:06,688 With spray we want a deal 584 00:29:07,200 --> 00:29:09,760 I know that sounds confusing but just bear with me 585 00:29:10,016 --> 00:29:12,320 What's go ahead to create a new function ok 586 00:29:13,344 --> 00:29:14,880 That's where it is 587 00:29:15,136 --> 00:29:16,928 Create a new function 588 00:29:17,952 --> 00:29:20,512 Let's go head go down here and we'll call this 589 00:29:21,024 --> 00:29:21,792 Public 590 00:29:22,560 --> 00:29:23,072 Lloyd 591 00:29:23,840 --> 00:29:25,632 Add inventory 592 00:29:27,168 --> 00:29:27,680 Ok 593 00:29:28,192 --> 00:29:31,264 Creating a new function called add inventory item 594 00:29:32,288 --> 00:29:35,872 Remember the syntax for creating functions is a little weird 595 00:29:36,128 --> 00:29:36,896 Ok 596 00:29:37,664 --> 00:29:38,944 So now we're going to have 597 00:29:39,968 --> 00:29:41,248 This line of code 598 00:29:42,016 --> 00:29:43,808 Copy that delete it 599 00:29:44,576 --> 00:29:48,928 I'm going to pierce that inside of a add inventory item function ok 600 00:29:49,184 --> 00:29:53,792 So technically everyone at do we can just go into the start here and go add inventory item 601 00:29:56,096 --> 00:29:59,168 You just gonna buy this line of code is double check 602 00:29:59,424 --> 00:30:02,496 So you absolutely 100-percent believe me 603 00:30:02,752 --> 00:30:05,312 Hasting that code into the new functions 604 00:30:05,568 --> 00:30:07,360 An infinite function inside of a star 605 00:30:08,128 --> 00:30:09,152 Is just fine 606 00:30:09,920 --> 00:30:10,944 As you can see 607 00:30:11,200 --> 00:30:11,968 The key 608 00:30:12,992 --> 00:30:13,760 Swapped 609 00:30:14,272 --> 00:30:15,040 So far 610 00:30:17,088 --> 00:30:21,440 What is this function what is this ad inventory function can allow us to do 611 00:30:22,720 --> 00:30:28,864 Remember you create functions in C Sharp so the chicken use them over and over and over again so they don't have to keep 612 00:30:29,120 --> 00:30:31,936 New code at all very similar to one another 613 00:30:32,448 --> 00:30:35,776 What is creating 1 new function that can do a lot of different things 614 00:30:36,032 --> 00:30:38,848 In this case we want to add inventory items 615 00:30:39,360 --> 00:30:41,152 Based on new strings 616 00:30:41,408 --> 00:30:42,432 A new sprite 617 00:30:43,456 --> 00:30:47,296 Create a new function that's going to allow us to add 618 00:30:47,552 --> 00:30:51,136 Different kinds of strings so IKEA trophy 619 00:30:51,392 --> 00:30:54,464 Gloves boots alternative inventory items 620 00:30:54,720 --> 00:30:55,744 To our player 621 00:30:56,000 --> 00:30:59,072 And also tell unity what does Sprite even is 622 00:31:00,608 --> 00:31:03,168 What we can do with something really cool with functions 623 00:31:03,424 --> 00:31:05,984 Not actually add parameters 624 00:31:06,752 --> 00:31:08,800 Remember how when we created this dictionary 625 00:31:09,312 --> 00:31:11,104 We said we can pass in a string 626 00:31:11,360 --> 00:31:12,384 And also a sprite 627 00:31:12,640 --> 00:31:15,200 Tony's case where passing inky one 628 00:31:15,456 --> 00:31:16,480 Anansi sprite 629 00:31:16,992 --> 00:31:19,296 You can do something similar when you create a function 630 00:31:19,552 --> 00:31:22,112 Security pass into a function 631 00:31:22,368 --> 00:31:23,136 Parameters 632 00:31:23,648 --> 00:31:24,928 I know that sound weird 633 00:31:25,184 --> 00:31:26,720 Go with me for one second 634 00:31:27,744 --> 00:31:30,816 If I said add inventory item 635 00:31:31,072 --> 00:31:32,864 This printer sees basically says 636 00:31:33,120 --> 00:31:36,704 Hey is there anything you want to tell me to do specifically 637 00:31:37,472 --> 00:31:39,776 Well we can actually pass in some parameters 638 00:31:40,288 --> 00:31:43,872 So what if I wanted this ad inventory out of function down here 639 00:31:44,128 --> 00:31:45,664 To be pretty specific 640 00:31:46,176 --> 00:31:48,480 What's the one of the 82 instead of 81 641 00:31:48,992 --> 00:31:53,088 What if I wanted instead of the key Sprite what if I wanted like a gem coloured spray 642 00:31:53,344 --> 00:31:54,368 The totally different spray 643 00:31:55,392 --> 00:31:57,696 Well you can actually use something called parameters 644 00:31:58,720 --> 00:32:00,768 And basically make a function 645 00:32:01,280 --> 00:32:02,304 Customisable 646 00:32:02,560 --> 00:32:05,632 In in specific to the information has been passed into 647 00:32:06,144 --> 00:32:10,496 Search for appear in take a look at the Calling of this ad inventory item function 648 00:32:10,752 --> 00:32:12,032 Play some pseudocode 649 00:32:13,568 --> 00:32:15,616 I want to add 650 00:32:15,872 --> 00:32:17,152 In inventory item 651 00:32:20,992 --> 00:32:21,504 Key 652 00:32:22,784 --> 00:32:24,832 With a Sprite of 653 00:32:25,344 --> 00:32:26,624 Ice Age MP 654 00:32:28,160 --> 00:32:30,720 What actually do that with these printers here 655 00:32:31,232 --> 00:32:36,096 I need been wondering where it is precious is even here for when you're calling functions well 656 00:32:36,608 --> 00:32:38,400 So are you doing something like 657 00:32:38,912 --> 00:32:40,448 String of T2 658 00:32:40,960 --> 00:32:41,984 And 659 00:32:42,496 --> 00:32:43,264 Tim key 660 00:32:45,312 --> 00:32:49,408 Bare with me I know it looks a little bit confusing but all were trying to do is 661 00:32:49,664 --> 00:32:52,224 Add an inventory item of T2 662 00:32:52,736 --> 00:32:54,016 With the djembe sprite 663 00:32:55,296 --> 00:33:01,440 Doesn't work exactly just yet we need actually tell the function what the parameters 664 00:33:01,696 --> 00:33:04,000 Right so we actually need to say 665 00:33:04,256 --> 00:33:08,864 Well you can have a string and that's going to be the inventory name 666 00:33:09,888 --> 00:33:10,400 Karma 667 00:33:10,912 --> 00:33:12,448 Aseprite 668 00:33:13,472 --> 00:33:14,240 Call Ben 669 00:33:14,752 --> 00:33:15,520 Image 670 00:33:15,776 --> 00:33:17,312 How you doing is creating this 671 00:33:17,568 --> 00:33:19,104 Temporary variables 672 00:33:19,360 --> 00:33:21,152 That we can pass information into 673 00:33:21,664 --> 00:33:22,944 In reference those 674 00:33:24,224 --> 00:33:28,576 So all we do is change this out from T12 inventory name 675 00:33:29,344 --> 00:33:31,392 And then we change this out to image 676 00:33:33,696 --> 00:33:36,000 So I know it's confusing 677 00:33:36,768 --> 00:33:38,048 Just bear with me here 678 00:33:38,560 --> 00:33:40,608 Add inventory item here 679 00:33:40,864 --> 00:33:42,400 Dysfunctions mean called 680 00:33:42,912 --> 00:33:45,216 Were passing into this function 681 00:33:45,472 --> 00:33:46,496 T2 682 00:33:47,008 --> 00:33:49,568 So literally because this is in the first 683 00:33:49,824 --> 00:33:51,616 Slot of the parameters 684 00:33:51,872 --> 00:33:53,920 It's saying ok watch string 685 00:33:54,688 --> 00:33:55,712 Can I pass well 686 00:33:55,968 --> 00:33:59,552 This inventory name is going to be this ketu 687 00:34:00,064 --> 00:34:02,624 Inventory dad is going to add 688 00:34:02,880 --> 00:34:03,904 Ketu 689 00:34:04,672 --> 00:34:05,952 Inventory dictionary 690 00:34:06,464 --> 00:34:08,256 Is going to add the gym key 691 00:34:08,768 --> 00:34:10,048 To the inventory as well 692 00:34:11,072 --> 00:34:12,864 Why you can see the gym key is 693 00:34:13,376 --> 00:34:16,704 Zigzag that's because we have an actually created the variable here 694 00:34:16,960 --> 00:34:19,264 So let's just go ahead and read that really quick 695 00:34:19,776 --> 00:34:23,616 Baby change the name of a little bit something like key jam 696 00:34:23,872 --> 00:34:24,896 Brighton 697 00:34:27,456 --> 00:34:29,504 Energies can be there and we'll pay that here 698 00:34:30,272 --> 00:34:31,040 Say it 699 00:34:31,808 --> 00:34:32,576 Now 700 00:34:33,088 --> 00:34:34,368 Add 701 00:34:35,392 --> 00:34:36,160 This 702 00:34:37,184 --> 00:34:38,208 Your inventory 703 00:34:38,720 --> 00:34:39,744 It also 704 00:34:40,000 --> 00:34:40,768 Simply 705 00:34:41,280 --> 00:34:42,560 Set this to 706 00:34:42,816 --> 00:34:45,120 Whenever that inventory name is ok 707 00:34:47,424 --> 00:34:48,192 Here we go 708 00:34:49,984 --> 00:34:52,032 So now we've created a function 709 00:34:52,544 --> 00:34:57,920 That allows us to add inventory items of whatever we choose 710 00:34:58,432 --> 00:35:02,272 Confusing so what we're going to do as we're going to save this 711 00:35:03,296 --> 00:35:04,320 How can I help play 712 00:35:06,624 --> 00:35:08,416 Just going to make sure it works right 713 00:35:09,696 --> 00:35:13,536 So so far it's broken it's confused 714 00:35:13,792 --> 00:35:15,840 Why is that I'm glad this happened 715 00:35:16,352 --> 00:35:17,376 If we jump back 716 00:35:17,632 --> 00:35:18,912 Into a script here 717 00:35:19,680 --> 00:35:20,448 Younotus 718 00:35:20,704 --> 00:35:23,520 We passing the gym key sprite 719 00:35:24,544 --> 00:35:28,384 The nearest when we fired the add inventory item function 720 00:35:28,896 --> 00:35:29,920 We were able 721 00:35:30,176 --> 00:35:31,968 To set the inventory item 722 00:35:32,224 --> 00:35:33,760 String to key 2 723 00:35:34,016 --> 00:35:35,808 Add that your inventory 724 00:35:37,088 --> 00:35:41,184 What does ygm spread even is we need to make sure we specify that 725 00:35:41,440 --> 00:35:44,256 In the parameters of jump back in the Unity 726 00:35:44,512 --> 00:35:48,352 Can you can see hear or keygen Sprite is nothing right 727 00:35:48,608 --> 00:35:50,912 So let's just go into a UI here 728 00:35:51,424 --> 00:35:52,704 Photoshop file 729 00:35:53,728 --> 00:35:56,032 So let's just right click on this inventory 730 00:35:56,288 --> 00:35:57,568 Current duplicate layer 731 00:35:58,336 --> 00:35:59,360 To call this 732 00:36:02,176 --> 00:36:03,968 And draganova 733 00:36:04,224 --> 00:36:06,528 Just use Jasmine's 734 00:36:07,040 --> 00:36:09,344 New saturation images colorizer 735 00:36:10,368 --> 00:36:13,184 If a colour is here maybe make the line is a little lower 736 00:36:13,440 --> 00:36:14,976 Bring up the saturation 737 00:36:15,232 --> 00:36:17,536 And let's make it a gem colour 738 00:36:18,304 --> 00:36:21,888 That green 739 00:36:22,144 --> 00:36:24,960 Turn that down and if we go back in the Unity 740 00:36:26,240 --> 00:36:29,312 What is important we now have the inventory jamke 741 00:36:30,336 --> 00:36:33,664 Remember we want to go into the spray editor just to double check here 742 00:36:34,432 --> 00:36:36,992 And make sure it's sized appropriately 743 00:36:37,248 --> 00:36:40,064 Remember this one's 105 this ones 105 744 00:36:40,320 --> 00:36:42,368 21 of 5 as well 745 00:36:42,880 --> 00:36:43,648 105 746 00:36:45,184 --> 00:36:49,792 And that is an image rage MP it's just wait because we've actually invert the colours 747 00:36:50,304 --> 00:36:52,608 Turn that off 748 00:36:52,864 --> 00:36:53,632 That's perfect 749 00:36:53,888 --> 00:36:54,912 Reply 750 00:36:55,936 --> 00:36:57,472 Sprite editor 751 00:36:57,984 --> 00:37:00,288 And remember guys we need that reference 752 00:37:00,544 --> 00:37:02,080 Tell inventory key jam 753 00:37:02,336 --> 00:37:04,384 Where did driver Torquay gym spray 754 00:37:05,408 --> 00:37:06,176 Here we go 755 00:37:07,456 --> 00:37:08,224 Now 756 00:37:08,480 --> 00:37:10,016 When we hit play 757 00:37:10,272 --> 00:37:12,832 That green junkie is going to show up 758 00:37:14,368 --> 00:37:15,136 There it is 759 00:37:16,928 --> 00:37:23,072 I'm sure a lot of you're watching this right now I'm thinking I don't know what the heck he just did 760 00:37:23,328 --> 00:37:29,216 Turn on blame you guys I feel the same way honestly I've been there I know exactly how it feels to just have 761 00:37:29,472 --> 00:37:33,056 Abstract code thrown in your face and it makes no sense 762 00:37:34,080 --> 00:37:35,616 I'm going to do a quick recap 763 00:37:36,384 --> 00:37:38,176 We create functions 764 00:37:38,944 --> 00:37:41,504 When we want to use code 765 00:37:41,760 --> 00:37:43,552 Over and over and over again 766 00:37:44,064 --> 00:37:48,160 Technically I could copy all of this information in here all this code 767 00:37:48,672 --> 00:37:50,208 And paste it here 768 00:37:50,464 --> 00:37:52,512 It will do the exact same thing right 769 00:37:52,768 --> 00:37:55,072 What I want to do it here too 770 00:37:57,120 --> 00:38:00,448 I got redundant code I'd like cold all over the place 771 00:38:00,960 --> 00:38:02,752 So that's why you put 772 00:38:03,008 --> 00:38:04,800 Simple lines of code 773 00:38:05,056 --> 00:38:06,080 In the functions 774 00:38:06,336 --> 00:38:12,224 The problem is sometimes you want a function to be a little bit more specific and not so generic 775 00:38:12,736 --> 00:38:18,880 The Way You Make It specific so for example if I wanted to add a key or a boot or 776 00:38:19,904 --> 00:38:25,024 The way you make functions more specific will also ensure that you can reuse them 777 00:38:25,536 --> 00:38:29,632 Is you pass through what's called parameters into your function 778 00:38:30,144 --> 00:38:35,520 So I have this function here and I've told you nearly that I want this function to pass in 779 00:38:36,032 --> 00:38:38,848 An inventory name and a string variable type 780 00:38:39,616 --> 00:38:40,896 In an image 781 00:38:41,152 --> 00:38:42,176 Which is a sprite 782 00:38:42,944 --> 00:38:45,248 I can pass in those two things 783 00:38:45,504 --> 00:38:46,272 NN 784 00:38:47,040 --> 00:38:50,368 Just have the inventory ad functions fire 785 00:38:50,624 --> 00:38:54,720 In regard to use the inventory name so whatever we set the string to 786 00:38:54,976 --> 00:38:56,256 And also this image 787 00:38:56,512 --> 00:38:59,328 Which these two are linked here at least your link here 788 00:39:00,608 --> 00:39:02,144 What we're not just adding 789 00:39:02,400 --> 00:39:08,032 A blank image we're adding the image that we said to use when we call this function 790 00:39:09,312 --> 00:39:11,360 So the images keygem sprite 791 00:39:12,384 --> 00:39:13,408 And also 792 00:39:13,664 --> 00:39:15,456 Keytool is the string 793 00:39:16,736 --> 00:39:20,064 Ok so we fired this function the moment unit B starts 794 00:39:21,088 --> 00:39:21,856 We called it 795 00:39:23,392 --> 00:39:25,440 And it's going to pass through 796 00:39:26,720 --> 00:39:28,512 The string key to 797 00:39:29,280 --> 00:39:32,096 Is it going to pass that through to here 798 00:39:32,608 --> 00:39:33,888 Add to the inventory 799 00:39:34,656 --> 00:39:35,936 Eventbrite 800 00:39:36,192 --> 00:39:37,984 Pass through 801 00:39:38,240 --> 00:39:38,752 Tahir 802 00:39:40,032 --> 00:39:45,664 Almost like a game of telephone except in this case he never screws up 803 00:39:45,920 --> 00:39:48,736 Right it's always going to know exactly what you want to do 804 00:39:48,992 --> 00:39:51,552 Because it's just saying ok you said to you too 805 00:39:52,064 --> 00:39:53,600 I'm gonna add that here 806 00:39:53,856 --> 00:39:55,648 You said keygem sprite 807 00:39:55,904 --> 00:39:56,928 I mean it had that here 808 00:39:57,440 --> 00:39:59,744 So what we can do all sorts of ways 809 00:40:00,256 --> 00:40:02,048 Add inventory item 810 00:40:02,560 --> 00:40:03,072 Cat 811 00:40:04,096 --> 00:40:05,632 And then we would just 812 00:40:06,144 --> 00:40:09,472 Say what's the spray was called cat spray 813 00:40:11,264 --> 00:40:14,080 You do a times you can do it all over the place 814 00:40:14,336 --> 00:40:15,872 You can do it here if you wanted to 815 00:40:16,128 --> 00:40:17,920 You can do it here if you want to do it 816 00:40:18,432 --> 00:40:20,480 Because this function is public 817 00:40:21,248 --> 00:40:24,064 We can actually do this from other scripts as well 818 00:40:24,320 --> 00:40:28,160 So what if we wanted an enemy to be able to steal your key 819 00:40:28,416 --> 00:40:30,976 Or maybe an enemy gives you a key 820 00:40:31,744 --> 00:40:36,352 You can just use this ad inventory I don't function from that script as well 821 00:40:36,608 --> 00:40:37,376 And it was just 822 00:40:37,632 --> 00:40:38,912 Call this function here 823 00:40:39,168 --> 00:40:41,216 And we can pass through specifics 824 00:40:41,472 --> 00:40:42,240 About function 825 00:40:43,264 --> 00:40:45,056 That's really all this is 826 00:40:45,824 --> 00:40:47,872 Listen guys I know I said it's a lot 827 00:40:48,384 --> 00:40:50,432 If you're confused it's ok 828 00:40:50,688 --> 00:40:51,968 Seriously it is ok 829 00:40:52,736 --> 00:40:55,808 Just keep moving along with me it's going to slowly make more sense 830 00:40:56,064 --> 00:40:57,600 Because when are we doing this a lot 831 00:40:58,112 --> 00:41:00,928 Passing through parameters through functions 832 00:41:01,184 --> 00:41:02,464 Where is variables 833 00:41:02,976 --> 00:41:04,512 It's gonna make sense I promise 834 00:41:04,768 --> 00:41:07,072 Just keep going going to make sense 835 00:41:08,096 --> 00:41:10,912 Alright so now that we have this function written 836 00:41:11,168 --> 00:41:12,448 We can actually start 837 00:41:12,704 --> 00:41:13,472 Creating 838 00:41:13,728 --> 00:41:16,032 A collectible item that looks like a key 839 00:41:16,288 --> 00:41:18,336 Habitat to work inventory 840 00:41:19,104 --> 00:41:23,712 For we do that jump into our new player script and just clean it up just a little bit 841 00:41:23,968 --> 00:41:26,784 What to do this often throughout these tutorials 842 00:41:27,040 --> 00:41:29,856 To make sure that everything's clean when I confuse here 843 00:41:30,368 --> 00:41:35,488 I don't really need some of these comments I like to clean so my comments Deramore pseudocode 844 00:41:36,000 --> 00:41:38,048 So don't get confused here 845 00:41:38,560 --> 00:41:42,400 We also don't want the key being added anymore that was just protesting so 846 00:41:42,656 --> 00:41:44,704 We can remove that we don't want to start with the key 847 00:41:45,728 --> 00:41:47,008 You say that out 848 00:41:47,520 --> 00:41:51,104 And let's see hear anything else I need to clean 849 00:41:52,128 --> 00:41:54,175 So far everything looks pretty good here 850 00:41:54,687 --> 00:42:00,831 Say that out if you guys need to add any comments to your script to remind yourself of exactly what's going on 851 00:42:01,087 --> 00:42:03,391 Feel free to do that right now and click cars 852 00:42:03,647 --> 00:42:04,415 Remember 853 00:42:04,671 --> 00:42:05,951 You can add comments 854 00:42:07,231 --> 00:42:08,767 Using two forward slashes 855 00:42:09,279 --> 00:42:12,863 So let's go ahead and create a new collectible type 856 00:42:13,119 --> 00:42:17,983 What's this first as a game object and then we can script it have to be created the game of chess 857 00:42:18,239 --> 00:42:19,775 Zoom in here 858 00:42:20,287 --> 00:42:21,567 Using a scroll wheel 859 00:42:22,079 --> 00:42:23,615 Inlets 860 00:42:23,871 --> 00:42:25,663 How to take this health 861 00:42:25,919 --> 00:42:27,967 Prefab copy and paste 862 00:42:29,503 --> 00:42:30,271 Alex Grey 863 00:42:31,039 --> 00:42:35,135 Now one thing we could do is we could just go to the spriterenderer here 864 00:42:35,647 --> 00:42:36,415 And 865 00:42:36,927 --> 00:42:38,975 Just change out this coin 866 00:42:40,255 --> 00:42:40,767 With 867 00:42:41,279 --> 00:42:41,791 The key 868 00:42:42,047 --> 00:42:43,583 Will you do that 869 00:42:44,095 --> 00:42:47,423 Well the problem here is that that's actually a you I love it 870 00:42:47,935 --> 00:42:51,007 Clear night you you are on it's a little bit different 871 00:42:51,263 --> 00:42:55,359 Then the actual game on Jackson Sprite in your game right in the actual world 872 00:42:55,871 --> 00:42:58,175 So what I like to do just to be careful 873 00:42:58,431 --> 00:42:59,455 I want to actually have 874 00:42:59,711 --> 00:43:02,527 A separate image for what's in the actual game 875 00:43:03,039 --> 00:43:09,183 Because he had any kind of icons on it for example if you were playing on the Xbox and you want to 876 00:43:09,439 --> 00:43:14,815 Use the key you might have a little y button icon overlapping the key 877 00:43:15,327 --> 00:43:16,863 It's really a UI element 878 00:43:17,375 --> 00:43:19,935 You don't really want that reflected in the game world 879 00:43:20,447 --> 00:43:23,263 So I'm going to do is right again a double click on level one here 880 00:43:24,031 --> 00:43:26,079 I'm just going to create a key 881 00:43:26,335 --> 00:43:28,895 Inside of this Photoshop file as well 882 00:43:29,407 --> 00:43:31,711 Just going to duplicate this over to level 1 883 00:43:32,223 --> 00:43:34,783 The right click and just go duplicate layer 884 00:43:35,551 --> 00:43:40,415 We actually choose which document we duplicate this layer into so we'll choose level one 885 00:43:40,927 --> 00:43:41,695 Ok 886 00:43:43,231 --> 00:43:46,815 And now we have this key and we can actually see oh ok it's pretty big 887 00:43:47,071 --> 00:43:48,863 So we actually just scale it down here 888 00:43:49,887 --> 00:43:50,911 Here 889 00:43:52,447 --> 00:43:58,079 And I'm just going to call this key is not really in inventory UI element adjuster key 890 00:43:58,591 --> 00:43:59,615 Say that 891 00:44:00,639 --> 00:44:02,687 And jump back in the Unity 892 00:44:05,247 --> 00:44:08,319 Once it's important we can just double check in the spray edit 893 00:44:08,831 --> 00:44:10,367 Remember we can't click this 894 00:44:11,391 --> 00:44:12,671 It's going to dark and everything 895 00:44:13,695 --> 00:44:15,231 Yeah we have a coin here 896 00:44:15,743 --> 00:44:17,023 We also have a key here 897 00:44:17,791 --> 00:44:18,303 So 898 00:44:19,327 --> 00:44:22,143 That's fine we don't actually need a match the sizes here 899 00:44:22,655 --> 00:44:23,167 Because 900 00:44:23,679 --> 00:44:25,471 The little bit different than you are 901 00:44:25,983 --> 00:44:30,079 Surrey XL this I can show you really quickly here for you select this health here 902 00:44:30,847 --> 00:44:32,383 I just swap it out with the key 903 00:44:33,919 --> 00:44:34,431 Good 904 00:44:34,687 --> 00:44:36,991 Like a proper size I like it 905 00:44:37,247 --> 00:44:39,551 So we have a tea here 906 00:44:40,319 --> 00:44:41,343 Be careful though 907 00:44:41,599 --> 00:44:43,647 You want to make sure we create a new prefab 908 00:44:44,415 --> 00:44:45,695 So let's go ahead 909 00:44:45,951 --> 00:44:47,743 Scroll down for prefab folder 910 00:44:49,535 --> 00:44:51,583 Shall we name this too key 911 00:44:52,863 --> 00:44:54,399 And we're just going to drag this 912 00:44:56,959 --> 00:44:59,007 What can I use in original prefab 913 00:45:00,543 --> 00:45:01,055 Ok 914 00:45:01,311 --> 00:45:02,847 What else do we need to do for this key 915 00:45:03,103 --> 00:45:07,455 I don't really want at Red so we're going to do maybe white fine for now 916 00:45:08,479 --> 00:45:10,783 And I also want to set the item type 2 917 00:45:11,295 --> 00:45:12,831 In England Tory item 918 00:45:13,343 --> 00:45:16,927 Will you have anything in here we have coin health m o 919 00:45:17,183 --> 00:45:19,231 We don't have an inventory item 920 00:45:20,255 --> 00:45:23,839 Does double click on a collectible script in just make sure that we add 921 00:45:24,351 --> 00:45:26,655 An inventory item 922 00:45:27,423 --> 00:45:27,935 As well 923 00:45:28,959 --> 00:45:29,727 Say that out 924 00:45:30,751 --> 00:45:31,775 Go back in the unit 925 00:45:32,799 --> 00:45:35,103 And then if you could the dropdown for item type 926 00:45:37,407 --> 00:45:39,199 If you choose inventory item 927 00:45:39,455 --> 00:45:42,783 Shall we apply the changes we just made this key 928 00:45:43,551 --> 00:45:44,831 The actual prefab 929 00:45:45,087 --> 00:45:46,367 Clicker player 930 00:45:47,135 --> 00:45:52,767 So when we had to go into this prefab here you can see the inventory item is set in it's also white 931 00:45:55,071 --> 00:45:55,583 Alright 932 00:45:56,095 --> 00:45:58,655 We have is inventory item this key 933 00:45:59,423 --> 00:46:02,239 So how do we actually ensure that when you collect it 934 00:46:02,751 --> 00:46:04,031 It does we want to 935 00:46:04,287 --> 00:46:05,055 Play 936 00:46:06,335 --> 00:46:08,383 Just to double check and make sure everything's working 937 00:46:08,639 --> 00:46:12,991 University is no longer updating because we remove that code from the start function 938 00:46:13,759 --> 00:46:15,039 The health 939 00:46:15,551 --> 00:46:16,575 What's good 940 00:46:16,831 --> 00:46:18,367 I can collect the key 941 00:46:18,623 --> 00:46:19,903 But nothing's happening 942 00:46:20,415 --> 00:46:23,743 That's because we're not actually firing any functions when we collect the key 943 00:46:24,255 --> 00:46:26,559 So we need to go outside of the collectible script 944 00:46:27,071 --> 00:46:28,095 Like that 945 00:46:28,863 --> 00:46:35,007 And because I want you clean freak here we're just going to remove all of this comment it all staff 946 00:46:35,263 --> 00:46:38,335 Need it anymore that was mainly just for reference 947 00:46:39,615 --> 00:46:41,663 We met up with between a place as well 948 00:46:42,687 --> 00:46:43,455 Alright 949 00:46:43,711 --> 00:46:45,759 Remember we have these conditions here 950 00:46:46,015 --> 00:46:48,063 If item type is a coin 951 00:46:48,319 --> 00:46:49,599 Then do this 952 00:46:49,855 --> 00:46:52,671 If I don't type is health then do this 953 00:46:53,439 --> 00:46:58,047 Is Adam type is going to do anything well that's right another else 954 00:46:58,303 --> 00:46:59,839 About else if 955 00:47:00,351 --> 00:47:01,631 Item type 956 00:47:02,655 --> 00:47:05,215 Equals item type dot 957 00:47:05,471 --> 00:47:06,239 It is 958 00:47:06,495 --> 00:47:07,519 Inventory item 959 00:47:08,287 --> 00:47:09,055 Then 960 00:47:10,591 --> 00:47:12,639 Do something you want to do 961 00:47:13,663 --> 00:47:16,223 Well that functions we wrote a new player 962 00:47:16,991 --> 00:47:19,551 Is function here and inventory item 963 00:47:20,319 --> 00:47:25,439 Now it's starting to make a little bit of sense hopefully so what we're going to do as we're going to say 964 00:47:25,695 --> 00:47:30,303 New player because member that function for adding Inventories inside 965 00:47:30,815 --> 00:47:31,839 Our new player 966 00:47:32,351 --> 00:47:33,119 Dad 967 00:47:34,911 --> 00:47:36,703 Add inventory item 968 00:47:37,471 --> 00:47:37,983 Well 969 00:47:38,239 --> 00:47:41,055 What do we want the inventory item to be 970 00:47:41,567 --> 00:47:44,127 Well let's just say he 14 now 971 00:47:46,175 --> 00:47:47,455 Add 972 00:47:47,711 --> 00:47:49,503 A Sprite in swap it out 973 00:47:49,759 --> 00:47:51,039 What spray is 974 00:47:51,807 --> 00:47:54,111 Well remember we have this variable here 975 00:47:55,135 --> 00:47:55,903 Key sprite 976 00:47:57,695 --> 00:47:59,743 We have inside of the player script 977 00:47:59,999 --> 00:48:02,559 Because we might want to use this key sprite 978 00:48:02,815 --> 00:48:03,839 All over the game 979 00:48:05,375 --> 00:48:06,143 We can just write 980 00:48:06,655 --> 00:48:07,423 New player 981 00:48:07,679 --> 00:48:09,215 Ducky spray 982 00:48:12,031 --> 00:48:13,311 And say that out 983 00:48:14,335 --> 00:48:19,967 And hopefully when we collect this item it's going to swap at us pray for us 984 00:48:22,271 --> 00:48:23,807 For that code compile 985 00:48:24,575 --> 00:48:25,343 And then hit 986 00:48:26,111 --> 00:48:26,623 Play 987 00:48:28,159 --> 00:48:29,695 We go at The Moment of Truth 988 00:48:31,487 --> 00:48:34,815 Let's grab that key and hopefully it swapped out 989 00:48:36,095 --> 00:48:37,887 It is we just got a key 990 00:48:38,655 --> 00:48:43,775 There's a couple of things we can do to make this a little bit more I guess robust in reusable 991 00:48:45,567 --> 00:48:47,615 When I was going to collect the one are we 992 00:48:47,871 --> 00:48:48,639 So 993 00:48:49,151 --> 00:48:50,175 Why do we do this 994 00:48:53,759 --> 00:48:56,063 Inventory string name 995 00:48:57,343 --> 00:48:58,623 International string 996 00:48:58,879 --> 00:48:59,903 That's a variable 997 00:49:00,159 --> 00:49:02,975 And it's creating a shred exam because again 998 00:49:03,231 --> 00:49:04,255 Doesn't exist 999 00:49:04,767 --> 00:49:05,279 Tell 1000 00:49:06,047 --> 00:49:08,351 Let's go how to create a new variable 1001 00:49:08,607 --> 00:49:10,655 In the collectible script when I called this 1002 00:49:10,911 --> 00:49:11,935 Private 1003 00:49:12,191 --> 00:49:13,215 String 1004 00:49:13,727 --> 00:49:14,751 Really call this 1005 00:49:15,007 --> 00:49:16,287 Exactly what we just typed 1006 00:49:16,543 --> 00:49:18,335 Inventory string names 1007 00:49:19,103 --> 00:49:21,919 And buy the faults going nothing right 1008 00:49:22,687 --> 00:49:27,039 We want to make sure that it's serialised so that it shows up in the inspector 1009 00:49:27,295 --> 00:49:29,343 So we're just going to type serialise 1010 00:49:31,391 --> 00:49:33,951 This area 1011 00:49:34,207 --> 00:49:34,975 Now 1012 00:49:35,743 --> 00:49:37,023 When we go 1013 00:49:37,279 --> 00:49:38,303 Unity here 1014 00:49:40,351 --> 00:49:41,631 Actually click on this key 1015 00:49:42,655 --> 00:49:43,167 Look 1016 00:49:43,679 --> 00:49:45,215 No I haven't even tie string name 1017 00:49:45,471 --> 00:49:48,287 So weekend had it be whatever we want we could have 1018 00:49:48,543 --> 00:49:50,335 Hijam or 1019 00:49:50,591 --> 00:49:52,127 Kie25 1020 00:49:52,383 --> 00:49:53,407 Orchy 1021 00:49:54,175 --> 00:49:57,759 Doesn't really matter he won now 1022 00:49:58,271 --> 00:49:58,783 Well 1023 00:49:59,039 --> 00:50:00,831 What's a little bit more specific 1024 00:50:01,343 --> 00:50:03,647 When we actually wanted to identify 1025 00:50:03,903 --> 00:50:04,927 The sprite 1026 00:50:05,183 --> 00:50:06,975 That's being used from here 1027 00:50:07,231 --> 00:50:08,255 Instead of 1028 00:50:08,511 --> 00:50:11,839 A generic key Sprite store globally in the new player 1029 00:50:12,607 --> 00:50:14,911 We can do one specific for this collectible 1030 00:50:15,423 --> 00:50:16,447 That sounds pretty cool 1031 00:50:16,703 --> 00:50:18,495 Serializefield 1032 00:50:18,751 --> 00:50:19,775 Private 1033 00:50:20,287 --> 00:50:23,103 It's going to be a Sprite and we're going to do 1034 00:50:23,871 --> 00:50:25,663 Inventory sprite 1035 00:50:29,759 --> 00:50:35,903 Now we can instead of doing the key Sprite we created earlier in the new player script we could have won 1036 00:50:36,159 --> 00:50:38,207 Specific to this collectible right 1037 00:50:38,463 --> 00:50:40,511 And that is inventory 1038 00:50:41,535 --> 00:50:42,303 Sprite 1039 00:50:45,119 --> 00:50:47,423 So just for purposes of this tutorial 1040 00:50:47,935 --> 00:50:52,287 If I was in miui and I wanted to create 1041 00:50:52,543 --> 00:50:56,127 Don't worry about wearing this guys I want to create a little :-) 1042 00:50:57,663 --> 00:50:58,687 I could call this 1043 00:50:58,943 --> 00:50:59,711 Smile 1044 00:51:00,479 --> 00:51:00,991 David 1045 00:51:01,247 --> 00:51:02,527 Unity here 1046 00:51:03,039 --> 00:51:04,831 And wait for that import 1047 00:51:06,111 --> 00:51:10,719 M and I could just literally drag this smile to my inventory spray 1048 00:51:12,511 --> 00:51:15,583 And I could call this inventory name I love smile 1049 00:51:16,095 --> 00:51:22,239 So we got one of the collect a smile object in the game well I can run over here and 1050 00:51:22,495 --> 00:51:24,543 Jump to grab this key 1051 00:51:25,055 --> 00:51:26,847 We just got to the smile 1052 00:51:27,359 --> 00:51:31,455 As you can see this ad inventory function is really valuable 1053 00:51:31,967 --> 00:51:34,527 Because it allows us to add a specific 1054 00:51:34,783 --> 00:51:39,391 String name for the inventory so in this case you collected a smile 1055 00:51:40,159 --> 00:51:43,999 You can also choose what that Sprite should look like 1056 00:51:44,255 --> 00:51:46,047 When you actually collect it here 1057 00:51:46,303 --> 00:51:48,095 Obviously we need to update 1058 00:51:49,119 --> 00:51:52,959 Display here with a smile for example something like that 1059 00:51:53,727 --> 00:51:54,751 I think you get the point 1060 00:51:55,007 --> 00:51:58,847 Now we can use that functions for a time of different inventory types 1061 00:52:00,383 --> 00:52:04,223 Now working on this ad inventory I don't function 1062 00:52:04,479 --> 00:52:08,575 Wickedest go ahead in create a remove inventory item function is well 1063 00:52:09,087 --> 00:52:13,439 There's a lot of ways we can do this I mean to do it in a way that makes the most sense 1064 00:52:13,695 --> 00:52:15,231 2 beginner coders 1065 00:52:15,487 --> 00:52:17,023 Again it's plenty ways to do this 1066 00:52:17,279 --> 00:52:21,887 Copy this function and create a new one will call it remove 1067 00:52:22,399 --> 00:52:23,167 Imagery 1068 00:52:23,423 --> 00:52:23,935 Adam 1069 00:52:25,983 --> 00:52:30,847 We can just literally change this ad to remove 1070 00:52:31,615 --> 00:52:32,639 And then also 1071 00:52:32,895 --> 00:52:39,039 When you're removing something from a dictionary you actually don't have two parameters are you have is this one all we need is 1072 00:52:39,295 --> 00:52:42,879 Inventory name get rid of this parameter as well 1073 00:52:44,159 --> 00:52:50,303 And then we also want to set the inventory item Sprite we don't actually have that Sprite reference 1074 00:52:50,815 --> 00:52:52,095 Actually the Creator 1075 00:52:52,607 --> 00:52:58,751 Up in a variable here so we have the key Sprite we have the key Jim spray that's another one public spray 1076 00:52:59,519 --> 00:53:00,543 Inventory 1077 00:53:01,055 --> 00:53:02,335 Adam blank 1078 00:53:03,359 --> 00:53:04,127 That's great 1079 00:53:07,455 --> 00:53:08,735 I just put that right here 1080 00:53:08,991 --> 00:53:10,527 Inventory item 1081 00:53:11,551 --> 00:53:12,063 Blink 1082 00:53:13,855 --> 00:53:18,975 So now we have the add inventory item function removing inventory item if we want to 1083 00:53:19,231 --> 00:53:21,791 Last thing you want to do is just jump back in the universe 1084 00:53:22,559 --> 00:53:27,167 Theremin player and just make sure that the blank inventory item spray is set 1085 00:53:27,679 --> 00:53:30,239 So we wanted to be this right here 1086 00:53:30,751 --> 00:53:33,567 Tell member if we go here it's right here just drag 1087 00:53:35,103 --> 00:53:35,871 That's great 1088 00:53:36,383 --> 00:53:39,711 So that will allow us to remove inventory item 1089 00:53:39,967 --> 00:53:46,111 And also add an inventory item with those two functions 77551

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.