All language subtitles for lesson104

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
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
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian Download
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
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,800 Ok so what's going make level 2 2 00:00:13,312 --> 00:00:15,360 I just press ctrl d 3 00:00:15,616 --> 00:00:17,408 With this level one selected here 4 00:00:18,944 --> 00:00:21,760 And I was just little 2 on it open today 5 00:00:23,040 --> 00:00:29,184 So just for the purposes of this tutorial that shift the player over to a start location of maybe here 6 00:00:29,952 --> 00:00:34,304 Let's maybe change all of these graphics back here 7 00:00:34,816 --> 00:00:39,168 Maybe not be purple but let's do full-time Game Dev till 8 00:00:39,936 --> 00:00:42,240 I like that brand colours so we do that 9 00:00:43,264 --> 00:00:45,568 Let's do a teal colour 10 00:00:46,848 --> 00:00:48,896 Something like that would be good 11 00:00:51,456 --> 00:00:53,248 I'm saying for this year 12 00:00:54,016 --> 00:00:55,552 Teal colour 13 00:00:57,088 --> 00:00:59,136 Increase the saturation 14 00:01:00,123 --> 00:01:03,003 Subtitled by -♪ online-courses.club ♪- We compress knowledge for you! https://t.me/joinchat/ailxpXoW3JVjYzQ1 15 00:01:03,004 --> 00:01:05,024 And it'll be a little bit messy right here bye 16 00:01:05,536 --> 00:01:09,888 Overground here maybe your platforms as well 17 00:01:10,912 --> 00:01:13,472 Select all of those is kind of 18 00:01:13,984 --> 00:01:15,264 Artistic 19 00:01:15,776 --> 00:01:17,568 You give me patient right 20 00:01:18,080 --> 00:01:24,224 And I maybe you can get this game done alright so let's go to blue here 21 00:01:24,480 --> 00:01:24,992 A girl 22 00:01:27,040 --> 00:01:28,064 Awesome 23 00:01:28,832 --> 00:01:30,112 It's pretty good 24 00:01:30,368 --> 00:01:31,648 And 25 00:01:31,904 --> 00:01:33,696 We don't really need to change the 26 00:01:34,464 --> 00:01:39,072 Black foreground here looks fine looks like we missed one here it's ok 27 00:01:40,352 --> 00:01:41,632 Use the eyedropper tool 28 00:01:42,912 --> 00:01:44,448 Tuesday dark blue 29 00:01:44,704 --> 00:01:47,264 In the final thing we want to do is just go to a camera this year 30 00:01:47,520 --> 00:01:52,640 Thermal camera how much like this boy here and maybe go a little prayer in a little bit later 31 00:01:53,408 --> 00:01:55,200 Alright so now 32 00:01:55,712 --> 00:01:56,992 Level two 33 00:01:58,528 --> 00:01:59,040 Rico 34 00:02:00,064 --> 00:02:06,208 Maybe ship some things around so maybe move that are here and I know this is just for the purpose 35 00:02:06,464 --> 00:02:12,608 This tutorial 36 00:02:13,376 --> 00:02:14,400 If you delete 37 00:02:17,216 --> 00:02:23,360 Dilip dad dad The Spinney here and 38 00:02:23,616 --> 00:02:24,384 Razor this 39 00:02:24,640 --> 00:02:27,456 Building here I don't know you guys get the portrait 40 00:02:28,480 --> 00:02:30,784 What is changing this level for this tutorial 41 00:02:31,552 --> 00:02:33,600 So we got bullied in the background 42 00:02:34,368 --> 00:02:37,440 We're clearly another to write colour just changed 43 00:02:37,696 --> 00:02:38,464 Awesome 44 00:02:39,232 --> 00:02:41,536 Play make sure everything works 45 00:02:47,680 --> 00:02:49,216 So now let's Create 46 00:02:50,752 --> 00:02:54,336 Trigger double load this level for us 47 00:02:54,848 --> 00:02:56,128 After we beat level 1 48 00:02:57,408 --> 00:02:58,944 Another one here 49 00:02:59,712 --> 00:03:03,296 What we're going to do is going to create a new empty gameobject 50 00:03:03,552 --> 00:03:06,368 I'm going to add a box Collider 2D to it 51 00:03:06,880 --> 00:03:08,160 It's going to be a Trigger 52 00:03:09,952 --> 00:03:16,096 What's use the scale tool in just sort of scale is up pretty back here something like this 53 00:03:16,352 --> 00:03:17,632 Just started to play a king 54 00:03:18,400 --> 00:03:20,960 Absolutely 100-percent can't avoid 55 00:03:21,728 --> 00:03:23,264 This little triggers on here 56 00:03:23,520 --> 00:03:27,360 This object seem load Trigger 57 00:03:28,128 --> 00:03:30,176 Shall we put that in to layer one here 58 00:03:30,432 --> 00:03:32,224 Where the player can walk 59 00:03:34,272 --> 00:03:37,088 There's no parallaxing are coming so they can we miss it 60 00:03:38,112 --> 00:03:41,184 Ok so you see shark script 61 00:03:41,440 --> 00:03:45,280 I'm really cold this scene load Trigger 62 00:03:46,304 --> 00:03:52,448 James Cranswick shares par for the course of the unity that's ok 63 00:03:52,704 --> 00:03:54,496 Lower trigger here 64 00:03:55,520 --> 00:03:57,824 Game object we can actually just drag this year 65 00:03:59,360 --> 00:04:02,432 And now we have the Script attached to a scene on trigger 66 00:04:02,688 --> 00:04:08,832 Let's just be sure to make cmode trigger a prefab cos they were going to be using this all right every levels 67 00:04:09,088 --> 00:04:11,392 Another level in we're going to have 68 00:04:11,648 --> 00:04:15,488 Linear game where we can go from one level to the next from left to right 69 00:04:16,256 --> 00:04:18,815 Ok let's go ahead in open up and see no Trigger 70 00:04:19,327 --> 00:04:23,935 And you probably guessed it were going to use on trigger enter 71 00:04:24,191 --> 00:04:30,335 Because I'm an idiot remember how the right ontriggerenter2d 72 00:04:31,103 --> 00:04:37,247 Copy it from the attack box here or we can do it from the enemy or anything like that just copying 73 00:04:37,503 --> 00:04:39,039 Delete the 74 00:04:39,295 --> 00:04:40,831 Inside of this function here 75 00:04:41,343 --> 00:04:44,927 Pseudocode anymore do it guys we just write this 76 00:04:45,183 --> 00:04:48,255 The collider2d which is col col 77 00:04:49,023 --> 00:04:51,583 Object equals 78 00:04:51,839 --> 00:04:52,863 New player 79 00:04:53,375 --> 00:04:55,423 Instant start game object 80 00:04:56,191 --> 00:05:01,567 Then later seen that again that was seen 81 00:05:02,079 --> 00:05:03,615 Manager 82 00:05:04,639 --> 00:05:05,407 Start 83 00:05:05,663 --> 00:05:07,967 Load scene ok 84 00:05:08,479 --> 00:05:13,087 And then we're going to load the next scene which is Level 2 85 00:05:15,391 --> 00:05:15,903 Perfect 86 00:05:17,439 --> 00:05:23,327 Looks like automatically it added a scene management namespace here that's pretty cool I didn't know it did that 87 00:05:23,583 --> 00:05:24,607 Assassin 88 00:05:24,863 --> 00:05:26,655 So if you don't see that 89 00:05:27,167 --> 00:05:28,703 Can you see a zigzag here 90 00:05:29,471 --> 00:05:31,519 I got to do is show potential fixes 91 00:05:32,799 --> 00:05:37,919 Enniskillen put that namespace in there which allows us actually love scenes 92 00:05:38,431 --> 00:05:44,575 Now summer thinking the timer sometimes with no one allowed a different seen maybe level 3 A level four 93 00:05:44,831 --> 00:05:46,623 Maybe another one or a main menu 94 00:05:47,647 --> 00:05:52,255 Thinking that's awesome it's crazy variable appear serializefield 95 00:05:52,767 --> 00:05:57,119 Give me a private string and loadscene string 96 00:05:59,935 --> 00:06:02,239 And we just remove everything here 97 00:06:04,799 --> 00:06:06,847 And then jump back in the Unity 98 00:06:07,359 --> 00:06:09,919 Now we can specify which 99 00:06:10,175 --> 00:06:11,455 Seen we're going to load 100 00:06:11,967 --> 00:06:13,503 Tennis Wigan lower level 101 00:06:14,015 --> 00:06:14,527 2 102 00:06:16,831 --> 00:06:18,367 Let's go head in 103 00:06:18,623 --> 00:06:21,183 That level 2 is added to a build 104 00:06:24,511 --> 00:06:27,327 There we go that means we can load level 2 now 105 00:06:29,631 --> 00:06:30,655 Play here 106 00:06:30,911 --> 00:06:31,935 And see if it works 107 00:06:32,191 --> 00:06:33,727 Let's go get a key 108 00:06:36,031 --> 00:06:37,055 This game 109 00:06:37,311 --> 00:06:42,431 I got the key here and avoid the enemy 110 00:06:42,943 --> 00:06:46,271 Open it up and let's load level two 111 00:06:46,527 --> 00:06:47,551 Perfect 112 00:06:47,807 --> 00:06:50,111 Alright level 2 just loaded 113 00:06:50,367 --> 00:06:53,439 That's awesome it's as you can see guys 114 00:06:54,207 --> 00:06:56,255 We have a very simple game loop 115 00:06:56,767 --> 00:07:01,375 Now we do have a problem if I collect 10 coins on other one 116 00:07:01,631 --> 00:07:02,911 Entry level 2 117 00:07:03,423 --> 00:07:05,471 The nearest Echoes back to 0 118 00:07:05,727 --> 00:07:07,263 So we go to the next one here 119 00:07:07,519 --> 00:07:08,543 It goes back to zero 120 00:07:09,567 --> 00:07:10,079 Well 121 00:07:10,335 --> 00:07:16,479 What if we wanted the player to be able to collect certain inventory items or maybe in 122 00:07:16,735 --> 00:07:22,879 Is there a health or decrease their health or the amount of coins they have in take those stats 123 00:07:23,135 --> 00:07:24,415 To the next level 124 00:07:25,183 --> 00:07:31,327 Now sometimes in games like Donkey Kong you want everything to just disappear and you start fresh 125 00:07:31,583 --> 00:07:37,471 On the next level I'm not really sure what you want for your game so I'm going to build out this tutorial 126 00:07:37,727 --> 00:07:39,263 So that works for both 127 00:07:39,519 --> 00:07:40,799 Permanent inventory 128 00:07:41,055 --> 00:07:46,943 Taking out from one level to the other but also the ability to clear out that inventory if you want 129 00:07:48,735 --> 00:07:52,575 Well if you recall inside of the new player 130 00:07:52,831 --> 00:07:57,183 C sharp script all of our inventory is stored 131 00:07:57,439 --> 00:08:03,583 Inside the script and includes the coins collected are hell my other items like that even 132 00:08:03,839 --> 00:08:09,983 Our inventory dictionary so everything is stored inside of this script so the moment that 133 00:08:10,239 --> 00:08:16,383 Load a new level it's going to destroy the player in the Script alongside of it so we need 134 00:08:16,639 --> 00:08:22,783 To ensure that the player doesn't get destroyed when we load into a new level 135 00:08:23,039 --> 00:08:25,343 We do that as we just go down the word start function here 136 00:08:25,599 --> 00:08:28,927 In all we do is create a new line of code 137 00:08:29,183 --> 00:08:35,327 That says don't destroy on load and then we just lost out this game object 138 00:08:36,351 --> 00:08:37,631 Well that's great 139 00:08:38,143 --> 00:08:41,983 That means that were not going to destroy the player but the problem is 140 00:08:42,239 --> 00:08:44,031 If we load into a new level 141 00:08:44,287 --> 00:08:49,919 There's a player in that level as well so that leaves us with two players 142 00:08:50,175 --> 00:08:51,199 Another problem 143 00:08:51,967 --> 00:08:56,063 So in order to ensure that we don't have two players 144 00:08:56,319 --> 00:08:57,855 Once level 2 is loaded 145 00:08:58,367 --> 00:09:00,671 Read actually destroy one player 146 00:09:00,927 --> 00:09:03,231 That is not the original player right 147 00:09:03,999 --> 00:09:07,839 So what we want to do is actually just jump into a new player script here 148 00:09:08,095 --> 00:09:12,959 And let's see here maybe on start and we could say something like 149 00:09:13,471 --> 00:09:15,775 If we find a game object 150 00:09:17,055 --> 00:09:18,591 Cold player 151 00:09:19,359 --> 00:09:21,151 Well we just destroy it 152 00:09:21,919 --> 00:09:23,711 Let me explain your sounds right 153 00:09:24,991 --> 00:09:27,039 50 magical find player 154 00:09:27,551 --> 00:09:28,063 Then 155 00:09:28,831 --> 00:09:30,623 We just destroy 156 00:09:32,159 --> 00:09:34,463 Me I can't type today can I 157 00:09:34,975 --> 00:09:36,255 Miracle 158 00:09:36,511 --> 00:09:39,327 So basically what this means is that second player 159 00:09:39,839 --> 00:09:41,119 Unravel 2 160 00:09:41,887 --> 00:09:44,191 If we find a game object 161 00:09:44,447 --> 00:09:47,519 Cold player meaning the original one that 162 00:09:47,775 --> 00:09:49,311 Came into our new scene 163 00:09:49,823 --> 00:09:53,663 Destroy Me destroy gameobject 164 00:09:53,919 --> 00:09:55,711 Don't say that out in 165 00:09:55,967 --> 00:09:58,015 Japan the level 2 and see if it works 166 00:09:58,527 --> 00:10:00,319 Play I should be good right 167 00:10:00,345 --> 00:10:03,400 Subtitled by -♪ online-courses.club ♪- We compress knowledge for you! https://t.me/joinchat/ailxpXoW3JVjYzQ1 168 00:10:03,401 --> 00:10:03,135 Lips 169 00:10:04,671 --> 00:10:06,207 Not good why is that 170 00:10:06,463 --> 00:10:08,767 That's because it sounded self 171 00:10:09,023 --> 00:10:10,815 So it destroyed itself 172 00:10:11,071 --> 00:10:12,607 We definitely don't want that 173 00:10:13,119 --> 00:10:16,447 This is also true for even level 1 if we go to level one 174 00:10:16,959 --> 00:10:17,983 Viaplay 175 00:10:18,751 --> 00:10:20,287 Destroy itself 176 00:10:21,311 --> 00:10:23,103 Not good we don't want that 177 00:10:23,359 --> 00:10:25,151 So how do we avoid this 178 00:10:25,663 --> 00:10:28,479 Well what if we were able to rename the player 179 00:10:28,991 --> 00:10:30,527 Say something like 180 00:10:31,551 --> 00:10:32,575 Game object 181 00:10:33,599 --> 00:10:34,879 That name 182 00:10:35,135 --> 00:10:37,951 Equals new player 183 00:10:40,255 --> 00:10:41,535 We Do It Like That 184 00:10:44,863 --> 00:10:46,143 Will that work 185 00:10:46,911 --> 00:10:49,471 Which shop in the unity in hip fly 186 00:10:49,727 --> 00:10:50,751 Another one 187 00:10:53,823 --> 00:10:56,383 Look we have a new name is called new player 188 00:10:57,151 --> 00:11:00,223 But I think there's a problem here what is that 189 00:11:00,479 --> 00:11:03,295 Well if we collect the key here grab the key 190 00:11:03,807 --> 00:11:05,343 Jump into the new scene 191 00:11:06,111 --> 00:11:07,647 Jokes that didn't work 192 00:11:07,903 --> 00:11:09,951 Another boat named new player 193 00:11:10,719 --> 00:11:14,559 So it's not actually gonna find anything called player in destroyed that 194 00:11:15,071 --> 00:11:16,863 So here's what we need to do 195 00:11:17,119 --> 00:11:19,423 We need to go ahead 196 00:11:19,935 --> 00:11:22,239 And use a new function 197 00:11:22,751 --> 00:11:24,031 Called a wake 198 00:11:24,543 --> 00:11:28,639 This is unity's clever way of making things a little bit easier for us 199 00:11:28,895 --> 00:11:31,967 Awake and start are basically the same 200 00:11:32,223 --> 00:11:35,039 Assist awake cabins before start 201 00:11:35,551 --> 00:11:38,111 It will always fire before start 202 00:11:38,879 --> 00:11:44,511 I think about maybe you wake up for the day so you nearly was a person you hit play 203 00:11:44,767 --> 00:11:46,047 He wakes up for the day 204 00:11:46,303 --> 00:11:50,143 And then he starts ok so on wake 205 00:11:51,167 --> 00:11:52,703 We need to search out 206 00:11:53,727 --> 00:11:59,871 In find if there is a game object called new player I see this 207 00:12:01,151 --> 00:12:02,687 But here 208 00:12:03,967 --> 00:12:10,111 We're going to look and see if there is a game object called new player ok 209 00:12:10,367 --> 00:12:14,207 What's that mean what the original player the one on level one 210 00:12:15,743 --> 00:12:16,767 Is it a wake up 211 00:12:17,535 --> 00:12:18,559 He's going to say 212 00:12:18,815 --> 00:12:22,143 Is there a game object called new player in the scene 213 00:12:22,911 --> 00:12:23,935 If there is 214 00:12:24,703 --> 00:12:25,727 Destroy himself 215 00:12:26,239 --> 00:12:27,007 Bad 216 00:12:27,263 --> 00:12:28,799 Because were renaming 217 00:12:29,567 --> 00:12:30,847 After awake 218 00:12:32,383 --> 00:12:34,431 He doesn't have a chance to destroy itself 219 00:12:35,455 --> 00:12:35,967 Ok 220 00:12:36,735 --> 00:12:40,063 Another word the start function we remind ourselves 221 00:12:40,575 --> 00:12:42,623 When we enter a new scene 222 00:12:43,135 --> 00:12:45,183 The player I'm level 2 223 00:12:45,695 --> 00:12:48,255 Will fire this when he wakes up 224 00:12:48,767 --> 00:12:51,071 And he is going to find a new player 225 00:12:52,607 --> 00:12:54,143 And he's going to destroy himself 226 00:12:55,167 --> 00:12:57,471 Mercedes SLK play 227 00:12:58,751 --> 00:13:01,055 And if it doesn't make sense guys that's ok 228 00:13:01,567 --> 00:13:05,663 Because I'm going to go through it again just say it makes absolutely perfect sense 229 00:13:05,919 --> 00:13:08,223 Outlook we are renamed to new player 230 00:13:08,479 --> 00:13:14,623 It can be any name you want if you want to do player original or first player animal care but I'm going to 231 00:13:14,879 --> 00:13:17,695 New player so it matches The Script 232 00:13:18,207 --> 00:13:20,767 I've got my key was got a little to here 233 00:13:22,815 --> 00:13:23,583 Perfect 234 00:13:24,095 --> 00:13:25,631 Ok to look 235 00:13:26,143 --> 00:13:27,423 Can you play a still there 236 00:13:28,447 --> 00:13:31,775 Still got all of my inventory about 2 coins that's great 237 00:13:32,799 --> 00:13:33,567 And 238 00:13:34,335 --> 00:13:36,383 Noticed how there's no more player here 239 00:13:36,895 --> 00:13:38,431 That player got destroyed 240 00:13:39,199 --> 00:13:41,759 Because I cannot take a look at the Script 241 00:13:44,063 --> 00:13:47,903 When the very first player on level 1 242 00:13:48,159 --> 00:13:53,279 When he wakes up he immediately thinks is there anything called new player 243 00:13:53,535 --> 00:13:59,679 Is there is anything called new player on this seen immediately destroy myself before doing anything 244 00:13:59,935 --> 00:14:00,959 Else in The Script 245 00:14:01,215 --> 00:14:03,007 I'm going to destroy myself 246 00:14:03,263 --> 00:14:06,591 Because I'm not needed is already something out there called new player 247 00:14:07,615 --> 00:14:08,127 Well 248 00:14:08,639 --> 00:14:10,943 If it doesn't find anything cold new player 249 00:14:11,455 --> 00:14:15,039 That means that this is the very first player 250 00:14:15,807 --> 00:14:19,391 So I get a move on to the start function this is the next 251 00:14:19,647 --> 00:14:21,183 Function that happens when you hit play 252 00:14:22,719 --> 00:14:24,767 Just going to rename myself to new player 253 00:14:25,023 --> 00:14:29,887 Ok I guess I'm the original player I'm gonna change my name it's going to be a new player 254 00:14:30,911 --> 00:14:31,679 Then 255 00:14:31,935 --> 00:14:33,471 When this player 256 00:14:33,727 --> 00:14:35,263 Loads into a new scene 257 00:14:36,799 --> 00:14:40,383 Another player in just for clarity here 258 00:14:41,151 --> 00:14:42,175 Save this out 259 00:14:42,943 --> 00:14:44,479 This player here 260 00:14:47,295 --> 00:14:48,319 He's going to wake up 261 00:14:48,575 --> 00:14:50,111 I'm awake 262 00:14:50,367 --> 00:14:51,391 What you going to do 263 00:14:51,647 --> 00:14:53,695 Is going to look for something called new player 264 00:14:54,207 --> 00:14:54,975 Well 265 00:14:55,743 --> 00:14:57,791 That old player from other one 266 00:14:58,303 --> 00:15:00,863 He loaded into the scene his name is new player 267 00:15:01,631 --> 00:15:03,679 Is the boss right he's in charge 268 00:15:04,703 --> 00:15:05,471 Because 269 00:15:05,983 --> 00:15:08,031 The level two player 270 00:15:08,543 --> 00:15:11,359 Found that game object called new player 271 00:15:12,639 --> 00:15:15,199 Bye-bye I get it I need to be destroyed 272 00:15:16,223 --> 00:15:17,759 And none of it is going to fire 273 00:15:19,295 --> 00:15:21,855 This ensures again two things guys 274 00:15:22,367 --> 00:15:28,511 This ensures that the player doesn't get destroyed when loading into a new scene that's important because we want to save over 275 00:15:29,791 --> 00:15:33,887 But it also ensures that we can test on level 2 if we want 276 00:15:34,399 --> 00:15:36,703 Watch if we start a mobile 2 and a play 277 00:15:36,959 --> 00:15:37,983 What happens 278 00:15:39,007 --> 00:15:41,055 You just get renamed to new player 279 00:15:41,567 --> 00:15:45,919 The means that he can go to another level he could take to clear the level 3 280 00:15:46,175 --> 00:15:48,991 Causing level 3 player to destroy 281 00:15:49,503 --> 00:15:50,527 Does that make sense 282 00:15:51,039 --> 00:15:57,183 It doesn't recommend we watching this video it's definitely not a complicated subject 283 00:15:57,439 --> 00:16:00,511 Not at all but it is weird and it's kind of abstract 284 00:16:01,023 --> 00:16:03,327 You'll get the hang of it I promise 285 00:16:04,351 --> 00:16:07,679 Now there's another problem here we will talk about in the next video 286 00:16:07,935 --> 00:16:12,287 You notice that when we load into level 2 the camera doesn't know what to look at Bray 287 00:16:12,799 --> 00:16:13,567 And also 288 00:16:13,823 --> 00:16:15,359 The UI is confused 289 00:16:15,615 --> 00:16:17,407 Show me the update those two things 290 00:16:17,663 --> 00:16:18,687 So if we 291 00:16:18,943 --> 00:16:21,503 Show battery level 2 in hip play here 292 00:16:22,527 --> 00:16:23,807 You noticed the camera 293 00:16:24,319 --> 00:16:26,367 Knows exactly what to follow 294 00:16:26,879 --> 00:16:29,183 Because if we click on the virtual camera here 295 00:16:29,439 --> 00:16:30,975 You can see follow is set to 296 00:16:31,231 --> 00:16:31,999 Player 297 00:16:32,255 --> 00:16:33,535 Because by the fault 298 00:16:33,791 --> 00:16:34,559 We told it to 299 00:16:34,815 --> 00:16:36,095 Before we hit play 300 00:16:36,863 --> 00:16:38,143 Follow as a player 301 00:16:38,911 --> 00:16:42,751 But if we load into level 2 from level 1 302 00:16:43,007 --> 00:16:45,567 Remember because of the Script we just wrote 303 00:16:46,079 --> 00:16:47,359 In the previous section 304 00:16:47,615 --> 00:16:49,663 Destroying that target 305 00:16:56,575 --> 00:16:57,599 So now 306 00:16:57,855 --> 00:16:58,623 The camera 307 00:16:58,879 --> 00:17:00,671 Has no idea what the follow 308 00:17:01,439 --> 00:17:07,327 Because we destroyed the player associated would love to while entering this new player 309 00:17:08,095 --> 00:17:11,935 So what we need to do is just basically tell this camera 310 00:17:12,191 --> 00:17:13,727 Is virtual camera here 311 00:17:13,983 --> 00:17:17,823 Right so we can actually do that with a new script 312 00:17:18,079 --> 00:17:19,615 Ok so let's create a new script 313 00:17:20,127 --> 00:17:21,407 Really call this 314 00:17:22,175 --> 00:17:23,199 Scene 315 00:17:23,455 --> 00:17:24,223 Camera 316 00:17:24,735 --> 00:17:30,879 We don't want to call it just camera because honestly unity has stuff out of the box that uses the term 317 00:17:31,135 --> 00:17:35,231 So seem camera 318 00:17:35,487 --> 00:17:37,279 Just to make it a little bit more unique 319 00:17:37,791 --> 00:17:41,375 To the cameras prefab and just drag 320 00:17:42,143 --> 00:17:44,191 This new scene camera script 321 00:17:44,959 --> 00:17:46,239 Under the main camera 322 00:17:47,519 --> 00:17:50,591 The first thing I want to do is reference the virtual camera 323 00:17:51,103 --> 00:17:53,151 Inside of this prefab 324 00:17:53,919 --> 00:17:55,199 So what are we doing here 325 00:17:55,711 --> 00:17:56,479 Generate 326 00:17:56,991 --> 00:17:58,527 Serialised 327 00:17:59,807 --> 00:18:01,343 Private 328 00:18:01,599 --> 00:18:02,623 Virtual 329 00:18:04,927 --> 00:18:09,023 Camera ok looks like we get cinemachine virtual camera look back 330 00:18:09,279 --> 00:18:10,303 You really call it 331 00:18:10,559 --> 00:18:11,583 Cinemachine 332 00:18:12,095 --> 00:18:13,119 Camera 333 00:18:15,423 --> 00:18:15,935 Alright 334 00:18:16,703 --> 00:18:20,031 Sonos how it automatically add the namespace here 335 00:18:20,287 --> 00:18:21,567 Using cinemachine 336 00:18:21,823 --> 00:18:22,847 You don't see this 337 00:18:23,103 --> 00:18:25,663 Go ahead and add this and that will allow us 338 00:18:25,919 --> 00:18:26,687 Make changes 339 00:18:27,199 --> 00:18:28,991 To the cinemachine virtual camera 340 00:18:29,503 --> 00:18:31,551 Alright say that John back in the Unity 341 00:18:32,063 --> 00:18:34,623 Inside of a camel's prefab hair ties 342 00:18:35,135 --> 00:18:37,183 So what we can do is actually just 343 00:18:37,439 --> 00:18:38,463 Drag 344 00:18:38,719 --> 00:18:39,999 The virtual camera 345 00:18:40,255 --> 00:18:41,791 To this for a slap here 346 00:18:43,071 --> 00:18:49,215 And any cameras prefab we use without level 1 or level 2 is going to have this reference 347 00:18:49,471 --> 00:18:51,007 So we can make adjustments 348 00:18:51,263 --> 00:18:52,543 12 camera 349 00:18:53,055 --> 00:18:55,103 From the scene camera script we have 350 00:18:55,359 --> 00:18:56,639 Save that 351 00:18:57,663 --> 00:18:59,711 What is double check and make sure it looks good 352 00:19:00,991 --> 00:19:03,039 OK Google everything was great 353 00:19:03,295 --> 00:19:06,623 What about level to take a look save that 354 00:19:07,647 --> 00:19:09,439 Let's go to main camera here 355 00:19:09,695 --> 00:19:10,463 Awesome 356 00:19:10,975 --> 00:19:15,071 We have seen camera here as well and it's referencing its virtual camera 357 00:19:15,583 --> 00:19:16,351 Awesome 358 00:19:18,911 --> 00:19:20,191 What can we do now 359 00:19:20,447 --> 00:19:21,727 We have access 360 00:19:21,983 --> 00:19:23,263 Universal camera 361 00:19:23,775 --> 00:19:25,567 What's double click on seeing camera here 362 00:19:26,335 --> 00:19:27,871 I must think about something here 363 00:19:28,127 --> 00:19:29,663 If 364 00:19:30,175 --> 00:19:31,711 Inside of new player 365 00:19:32,479 --> 00:19:34,015 Where destroying 366 00:19:35,039 --> 00:19:37,855 That level 2 player 367 00:19:38,879 --> 00:19:40,927 Doing it on a wig 368 00:19:41,439 --> 00:19:43,999 Then technically if we do something in start 369 00:19:45,023 --> 00:19:47,327 It's happening after a week right 370 00:19:48,351 --> 00:19:51,935 So after we've destroyed that level 2 player 371 00:19:52,447 --> 00:19:56,799 Then I guess what we can do inside a start with the right this pseudocode 372 00:19:57,311 --> 00:19:58,079 Set 373 00:19:58,335 --> 00:19:59,615 Cinemachine 374 00:20:00,895 --> 00:20:04,223 Virtual can't type 400 camera 375 00:20:04,735 --> 00:20:05,759 Target 376 00:20:06,271 --> 00:20:08,063 To be the new player 377 00:20:10,367 --> 00:20:13,951 How do we write that out with actual script 378 00:20:15,999 --> 00:20:17,023 We could say 379 00:20:17,535 --> 00:20:18,559 On start 380 00:20:18,815 --> 00:20:21,631 Cinemachine virtual camera double click 381 00:20:21,887 --> 00:20:23,423 Follow 382 00:20:23,679 --> 00:20:27,775 And then all we got to do is set it to new player that instance 383 00:20:28,031 --> 00:20:29,823 Transform 384 00:20:33,919 --> 00:20:37,759 Let's make sure this works what it does will just do a quick recap 385 00:20:38,271 --> 00:20:39,039 Everything 386 00:20:39,807 --> 00:20:41,855 So let's hit play 387 00:20:42,367 --> 00:20:45,695 And that start function is going to fire right now 388 00:20:46,207 --> 00:20:49,535 And it's going to look for the new player instance there it is so 389 00:20:50,047 --> 00:20:54,911 Change it change it still did The Script so it said it 390 00:20:55,423 --> 00:20:56,191 To be 391 00:20:56,703 --> 00:20:59,263 On the new player instant so kind of follow this 392 00:20:59,519 --> 00:21:01,823 We could even just to show you 393 00:21:02,591 --> 00:21:04,127 We could remove 394 00:21:05,919 --> 00:21:07,711 This all together 395 00:21:08,991 --> 00:21:14,879 So now it doesn't know what to follow but because we have that new script that happens on start when we hit play 396 00:21:15,391 --> 00:21:16,416 It's going to find 397 00:21:17,696 --> 00:21:19,744 The new player instance and start following 398 00:21:20,768 --> 00:21:23,072 This loading a level 2 and see if it works 399 00:21:27,168 --> 00:21:28,448 Perfect it does 400 00:21:28,960 --> 00:21:33,312 Now it's actually it's not on the right side here because it's been confined 401 00:21:33,568 --> 00:21:35,616 Be that polygon Cameron fighter 402 00:21:36,640 --> 00:21:37,664 What it works 403 00:21:37,920 --> 00:21:39,712 And that's exactly what we wanted 404 00:21:39,968 --> 00:21:43,296 Just double check what exactly just happened 405 00:21:43,808 --> 00:21:45,088 So here is the truth 406 00:21:45,344 --> 00:21:47,904 When we immediately load into level 2 407 00:21:48,416 --> 00:21:51,232 There's actually two instances of new player 408 00:21:51,744 --> 00:21:56,352 So if this was inside of a wake and not start number awake happens before start 409 00:21:56,864 --> 00:21:58,656 Is this was inside of a week 410 00:21:58,912 --> 00:22:00,960 Unity with bow window what to do 411 00:22:01,728 --> 00:22:06,080 Because it's inside a start in we've already destroyed 412 00:22:06,592 --> 00:22:07,872 The level two player 413 00:22:08,128 --> 00:22:09,152 Awake 414 00:22:09,408 --> 00:22:11,968 Inside a start there's only one 415 00:22:12,480 --> 00:22:13,504 Fire inserts 416 00:22:14,016 --> 00:22:16,576 So we can immediately just said it to that player 417 00:22:17,088 --> 00:22:22,464 The Masons guys I understand I know it a little bit confusing go ahead and watch this video again 418 00:22:22,720 --> 00:22:24,512 Try and wrap your mind around 419 00:22:24,768 --> 00:22:26,816 The sequence of events of what's happening 420 00:22:27,584 --> 00:22:33,728 I got it and this is by far one of the most confusing part of making games and honestly I am 421 00:22:33,984 --> 00:22:39,872 Working on the loading scenes portion of a game because there's kind of a lot of 422 00:22:40,128 --> 00:22:42,944 Idiosyncrasies in weird sequences of events 423 00:22:43,456 --> 00:22:49,600 For clarity here before we jump into actually changing the spawn location let's just 424 00:22:49,856 --> 00:22:51,392 Quickly review with gone on here 425 00:22:51,904 --> 00:22:52,672 So 426 00:22:52,928 --> 00:22:55,232 The very first thing that happens in this game 427 00:22:55,488 --> 00:22:57,792 At the very beginning when we hit play 428 00:22:58,304 --> 00:23:01,376 We check and see if there's a game object called new player 429 00:23:02,144 --> 00:23:02,656 Now 430 00:23:02,912 --> 00:23:08,544 If you're starting on level 10 starting in any seen really and hitting the play button in the unity editor 431 00:23:09,056 --> 00:23:10,592 There is nothing called new player 432 00:23:10,848 --> 00:23:11,872 Why is that 433 00:23:12,128 --> 00:23:16,224 Because immediately after this that's when we rename something to new player 434 00:23:17,248 --> 00:23:17,760 Ok 435 00:23:18,016 --> 00:23:19,808 To the very first player 436 00:23:20,320 --> 00:23:23,392 You experienced this line of code but he won't destroy himself 437 00:23:24,672 --> 00:23:30,816 Then we go to start and he'll just remind himself this is basically I'm saying I'm the boss and my name is new player 438 00:23:31,328 --> 00:23:34,656 So when new player walks in the level 2 439 00:23:35,424 --> 00:23:37,216 Level 2 player 440 00:23:37,984 --> 00:23:39,520 He's going to destroy himself 441 00:23:40,032 --> 00:23:43,616 Because he's not needed because the boss just came into the world 442 00:23:43,872 --> 00:23:46,688 The guy who owns the game right 443 00:23:46,944 --> 00:23:50,016 The protagonist the boss what do this level on said 444 00:23:50,272 --> 00:23:51,296 I'm new player 445 00:23:51,552 --> 00:23:52,576 You're not needed 446 00:23:52,832 --> 00:23:56,416 Dad player on level to destroy himself 447 00:23:56,928 --> 00:24:00,768 Therefore saving Oliver data from the original player from other one 448 00:24:01,024 --> 00:24:01,536 Ok 449 00:24:02,304 --> 00:24:05,888 And that's all because awake in Star happened at different times 450 00:24:07,424 --> 00:24:10,496 Then we also created a script called seeing camera 451 00:24:11,008 --> 00:24:17,152 And all were doing with this is were saying the moment that we start not awake but start 452 00:24:17,408 --> 00:24:18,944 Start happens after a week 453 00:24:19,712 --> 00:24:21,248 The moment we start 454 00:24:21,504 --> 00:24:22,272 The game 455 00:24:23,296 --> 00:24:25,088 I'm going to change 456 00:24:25,856 --> 00:24:27,392 The follow target 457 00:24:27,648 --> 00:24:29,440 Cinemachine virtual camera 458 00:24:29,952 --> 00:24:30,720 To be 459 00:24:30,976 --> 00:24:32,512 The new player instance 460 00:24:33,280 --> 00:24:35,328 Now if we didn't destroy 461 00:24:36,352 --> 00:24:40,704 Level two player and we had two instances of the player 462 00:24:42,240 --> 00:24:44,544 Cinemachine would be very confused 463 00:24:44,800 --> 00:24:45,824 Unfortunately 464 00:24:46,592 --> 00:24:50,176 Because we destroy level 2 player in wake 465 00:24:51,200 --> 00:24:52,736 Once we move on to start 466 00:24:54,784 --> 00:24:55,808 He knows who to follow 467 00:24:56,576 --> 00:24:58,112 It's important to note here guys 468 00:24:58,368 --> 00:24:59,392 That's start 469 00:24:59,648 --> 00:25:04,000 Doesn't have some kind of local sequence of events to see in camera 470 00:25:04,512 --> 00:25:08,864 Start in a week in both scripts happen at the same time 471 00:25:09,632 --> 00:25:15,776 So this awake script fires before this start and it fires before the start 472 00:25:18,336 --> 00:25:20,128 It Moves onto this start here 473 00:25:21,664 --> 00:25:24,480 And also the Script will run the start 474 00:25:25,248 --> 00:25:30,368 Important to think of both of the start functions is happening in sequence after 475 00:25:31,904 --> 00:25:32,928 Is awake 476 00:25:33,440 --> 00:25:34,208 Function 477 00:25:35,232 --> 00:25:38,816 I know that's confusing again this is not complicated 478 00:25:39,072 --> 00:25:45,216 What is abstract in a bit weird so if this doesn't make sense I encourage you to watch this video just one more 479 00:25:45,728 --> 00:25:47,776 Train wrap reminder around what's going on 480 00:25:48,032 --> 00:25:53,152 The last thing we want to talk about when loading into a new scene is spawn sounds 481 00:25:53,664 --> 00:25:59,808 We could just move the player around right and have him spawn here that sounds 482 00:26:00,576 --> 00:26:02,368 What have you moved into level 2 483 00:26:02,624 --> 00:26:04,416 You're moving a level 2 484 00:26:04,672 --> 00:26:09,280 Is going to actually just stay exactly where he was in the previous scene 485 00:26:09,792 --> 00:26:12,096 Does it play Now show you exactly what we're doing here 486 00:26:13,632 --> 00:26:14,144 Ok 487 00:26:14,912 --> 00:26:15,936 Salad 488 00:26:16,192 --> 00:26:18,752 Take a look at the players current position 489 00:26:19,264 --> 00:26:21,824 His position is Curley 18 490 00:26:22,336 --> 00:26:26,432 60k 18 on the x-axis and 6 on the Y 491 00:26:26,944 --> 00:26:30,272 If we run over here is a 20 up look 492 00:26:30,784 --> 00:26:32,064 On the new level 493 00:26:32,320 --> 00:26:33,856 He's at the same position 494 00:26:34,368 --> 00:26:35,392 Unit 21 495 00:26:35,904 --> 00:26:36,928 Nn6 496 00:26:37,440 --> 00:26:38,208 Tell 497 00:26:38,720 --> 00:26:40,768 You didn't respond and move 498 00:26:41,024 --> 00:26:43,072 We really want him to move over here 499 00:26:43,328 --> 00:26:45,120 That will be one of the spine 500 00:26:45,632 --> 00:26:47,680 Tell the way you going to do this is 501 00:26:47,936 --> 00:26:49,216 We could technically 502 00:26:49,472 --> 00:26:51,264 Input values 503 00:26:51,520 --> 00:26:56,896 Into a variable like a spawn position variable evektor to 504 00:26:57,408 --> 00:27:00,992 But I find it easier actually just to create an empty gameobject 505 00:27:01,504 --> 00:27:02,272 Call it 506 00:27:02,528 --> 00:27:04,320 Spawn location 507 00:27:05,088 --> 00:27:06,880 And then we can just move this 508 00:27:07,136 --> 00:27:09,440 Around where we need the player to spawn 509 00:27:10,208 --> 00:27:12,512 Somewhere about right here 510 00:27:13,792 --> 00:27:16,096 Because they use this 511 00:27:16,352 --> 00:27:17,632 On every single level 512 00:27:17,888 --> 00:27:20,448 So now we have a game object called spawn location 513 00:27:21,472 --> 00:27:23,776 We just go to our new player script 514 00:27:24,032 --> 00:27:27,360 Are we going to do now is basically on start 515 00:27:28,384 --> 00:27:34,528 See hear about right here we're just going to say transform that position = game on 516 00:27:34,784 --> 00:27:35,296 That's fine 517 00:27:37,088 --> 00:27:41,952 Is the average cased gamer bigger find spawn location 518 00:27:42,208 --> 00:27:43,744 Transform 519 00:27:44,256 --> 00:27:45,536 That position 520 00:27:47,584 --> 00:27:49,632 So we're going to move the player 521 00:27:50,400 --> 00:27:52,960 To the spawn location 522 00:27:53,472 --> 00:27:54,752 That's great was straight out 523 00:27:56,288 --> 00:28:02,432 Just for clarity here let's move the player somewhere kinda crazy so maybe like to put him at the 0 position 524 00:28:02,944 --> 00:28:04,992 Just for cleanliness a crate 525 00:28:05,760 --> 00:28:07,552 And he should spine 526 00:28:07,808 --> 00:28:09,088 Three spawn location 527 00:28:09,600 --> 00:28:10,880 Because we put that script 528 00:28:11,392 --> 00:28:12,416 In the start function 529 00:28:14,208 --> 00:28:14,720 Awesome 530 00:28:15,232 --> 00:28:16,256 So he just Bond 531 00:28:18,048 --> 00:28:21,120 Rayquaza spawn location was that's perfect 532 00:28:21,376 --> 00:28:23,168 Well there's a problem though 533 00:28:23,680 --> 00:28:28,288 Remember at the start function is going to happen one time when we start the game 534 00:28:29,056 --> 00:28:33,408 So what we want to do is actually have this transformed at position 535 00:28:33,920 --> 00:28:40,064 Equals to spawn location position we want this to happen after we load into the new seen as well 536 00:28:41,088 --> 00:28:43,648 So how are you this footsie here 537 00:28:43,904 --> 00:28:45,696 Well if we go to our 538 00:28:46,208 --> 00:28:47,488 Simo Trigger 539 00:28:49,536 --> 00:28:51,840 We definitely can put it here like this 540 00:28:52,096 --> 00:28:57,472 Because we're outside of the new player script we need to make sure we reference new player that instance 541 00:28:57,728 --> 00:29:00,544 Gameobject transform deposition 542 00:29:02,080 --> 00:29:04,896 So now it's going to load the scene 543 00:29:05,152 --> 00:29:07,712 Once you engage with the see no Trigger 544 00:29:08,224 --> 00:29:10,528 And then I'm going to change the position of a player 545 00:29:11,296 --> 00:29:13,088 In magic to the spine location 546 00:29:13,344 --> 00:29:14,368 Of the next level 547 00:29:14,880 --> 00:29:17,440 The thing is is that the moment we load a scene 548 00:29:17,696 --> 00:29:23,840 Unity has to wait for this load to occur so literally the framerate will drop to zero until the 549 00:29:24,096 --> 00:29:26,912 Scene is loaded in destroyed the Old scene 550 00:29:27,424 --> 00:29:29,728 And then we're going to actually be able to find 551 00:29:29,984 --> 00:29:31,264 The new spine location 552 00:29:31,520 --> 00:29:32,544 Deposition the player 553 00:29:33,056 --> 00:29:34,336 Balustrade 554 00:29:34,592 --> 00:29:37,408 So first on start because of a new player script 555 00:29:38,688 --> 00:29:43,296 It's going to send us to the spawn location again that's because of this right here 556 00:29:43,552 --> 00:29:45,600 Any start functions of the new player script 557 00:29:46,880 --> 00:29:49,440 And then when we get the key and go to the next level 558 00:29:52,000 --> 00:29:53,024 He gets repositioned 559 00:29:54,816 --> 00:29:55,328 Perfect 560 00:29:56,096 --> 00:30:00,704 That's awesome everything wants to be working just fine now your notice we have 561 00:30:01,472 --> 00:30:06,336 Some references issues here so we're going to address those in the next section 562 00:30:06,848 --> 00:30:07,360 However 563 00:30:07,616 --> 00:30:09,408 I want to make something Clear here 564 00:30:10,432 --> 00:30:11,712 If we take a look 565 00:30:12,224 --> 00:30:15,040 At the scene won't trigger we have this right here 566 00:30:16,064 --> 00:30:19,136 This is actually a little bit redundant because 567 00:30:19,392 --> 00:30:22,464 Pretty much doing the same thing in this script as well 568 00:30:23,232 --> 00:30:25,536 So how can we make this a little bit cleaner 569 00:30:26,048 --> 00:30:27,584 When we create a function 570 00:30:27,840 --> 00:30:28,608 And call it 571 00:30:29,120 --> 00:30:35,264 Public void set spawn position and replace inside of a new player script 572 00:30:35,520 --> 00:30:36,032 Ok 573 00:30:37,312 --> 00:30:39,104 And then we can just literally 574 00:30:39,616 --> 00:30:41,152 Have the position change 575 00:30:41,664 --> 00:30:43,200 Finding a spawn location 576 00:30:43,712 --> 00:30:46,528 That way all we got to do is take this appear 577 00:30:47,040 --> 00:30:49,856 In the start function set spawn position 578 00:30:50,624 --> 00:30:52,416 Going to call that function for us 579 00:30:52,928 --> 00:30:55,744 Do the same thing here as well 580 00:30:56,256 --> 00:30:59,328 Make sure you do new player that instance 581 00:30:59,840 --> 00:31:01,376 Set spawn position 582 00:31:01,888 --> 00:31:08,032 The reason why we doing that guys if we ever wanted to change something about how a spawn a curse so for example 583 00:31:08,288 --> 00:31:11,872 We wanted to animal play a sound effect we can go 584 00:31:12,128 --> 00:31:17,504 No audio source won't talk about audio in another episode audiosource stop play sound 585 00:31:17,760 --> 00:31:19,296 Spawn sound you know 586 00:31:19,552 --> 00:31:23,136 If you wanted to do that we can just do a once in this function 587 00:31:23,904 --> 00:31:24,928 NN 588 00:31:25,184 --> 00:31:30,560 Anytime we set the spawn position of the player weather is on start appear 589 00:31:30,816 --> 00:31:31,840 Or whether it's 590 00:31:32,096 --> 00:31:33,888 Not occurring AC mode Trigger 591 00:31:34,400 --> 00:31:36,192 Will have to write that twice 592 00:31:36,448 --> 00:31:38,496 It's just referencing that one function 593 00:31:39,520 --> 00:31:43,616 And also guys miss you open up the collectible script here and 594 00:31:43,872 --> 00:31:50,016 We're gonna simply change this from collision gameobject name to remove this in with just going to simply 595 00:31:50,528 --> 00:31:54,368 Use the Instance of the new player so new player 596 00:31:55,136 --> 00:31:57,696 Instance Die game object 597 00:31:58,464 --> 00:31:59,232 Here we go 43014

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