All language subtitles for lesson098

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:11,520 Alright so some of you then probably wondering 2 00:00:11,776 --> 00:00:15,872 Thomas why are you not using the Singleton pattern 3 00:00:16,640 --> 00:00:21,248 Now some of you are thinking what the heck is a Singleton pattern 4 00:00:21,504 --> 00:00:23,296 Well let's jump into you 5 00:00:23,808 --> 00:00:25,344 Are collectible script here 6 00:00:26,112 --> 00:00:27,392 Take a look at something 7 00:00:28,160 --> 00:00:33,280 We have a new player variable to that we actually have a reference to the new player component 8 00:00:34,560 --> 00:00:37,376 Welsh Everytime We create a script correctly 9 00:00:37,632 --> 00:00:40,704 We have to create a new reference 10 00:00:41,472 --> 00:00:42,240 To the new player 11 00:00:43,264 --> 00:00:44,544 Frustrating 12 00:00:44,800 --> 00:00:46,336 We do that again as well so 13 00:00:47,104 --> 00:00:50,432 A magical find player that getcomponent new player 14 00:00:50,944 --> 00:00:53,248 This is redundancy in Multiple scripts 15 00:00:53,504 --> 00:00:54,528 It's kind of annoying 16 00:00:54,784 --> 00:00:56,064 If we had an enemy scratch 17 00:00:56,320 --> 00:00:58,624 We also have to write this out in that 18 00:00:59,136 --> 00:01:00,525 If we had an NPC script 19 00:01:00,527 --> 00:01:02,875 Subtitled by -♪ online-courses.club ♪- We compress knowledge for you! https://t.me/joinchat/ailxpXoW3JVjYzQ1 20 00:01:02,876 --> 00:01:02,464 We have to write it out there 21 00:01:02,976 --> 00:01:09,120 We been writing it out probably 100 to 200 times for a final game and I can actually admit that 22 00:01:09,376 --> 00:01:10,912 Striped my very first game 23 00:01:11,168 --> 00:01:11,936 Does this 24 00:01:12,704 --> 00:01:15,776 The alternative is to use something called a Singleton 25 00:01:16,288 --> 00:01:22,432 A Singleton basically refers to a game object that is easily reachable from 26 00:01:22,688 --> 00:01:25,760 Anywhere in there only exists one of these 27 00:01:26,016 --> 00:01:31,648 At any given time to have more or less than one of these game objects 28 00:01:32,416 --> 00:01:35,744 Set a player game object with the new player component 29 00:01:36,256 --> 00:01:38,304 Is actually a Prayer example 30 00:01:38,816 --> 00:01:39,840 Have a Singleton 31 00:01:40,096 --> 00:01:43,936 Because it's only ever one thing in the entire game 32 00:01:44,192 --> 00:01:45,984 You never going to have multiple players 33 00:01:46,240 --> 00:01:46,752 Right 34 00:01:47,008 --> 00:01:49,824 So if I want any script that I create 35 00:01:50,080 --> 00:01:51,872 To be able to reference this player 36 00:01:52,128 --> 00:01:56,224 Whenever I want without requiring me right out this 37 00:01:56,480 --> 00:01:57,248 Horrible 38 00:01:57,760 --> 00:02:00,576 Line of code gameobject find player that pony 39 00:02:01,600 --> 00:02:04,672 If I want to avoid writing this all the time 40 00:02:04,928 --> 00:02:06,208 Then what I need to do 41 00:02:06,720 --> 00:02:07,488 Is simply 42 00:02:08,256 --> 00:02:09,536 Make this new player 43 00:02:10,304 --> 00:02:11,840 A Singleton instance 44 00:02:12,864 --> 00:02:13,888 It sounds confusing 45 00:02:14,144 --> 00:02:15,680 The words are kind of strange 46 00:02:16,192 --> 00:02:20,800 And when you look at the code it's going to be even stranger and trust me and strange to me too 47 00:02:21,056 --> 00:02:25,152 Actually haven't even memorise this code and the reason I haven't memorised it is 48 00:02:25,408 --> 00:02:28,992 Well to Singleton you only use it once you write this code once 49 00:02:29,248 --> 00:02:31,808 Any allows you to do so much 50 00:02:32,064 --> 00:02:33,344 For your entire game 51 00:02:33,600 --> 00:02:37,184 Oh really you're probably only going to write this line of code that were about 2 52 00:02:37,440 --> 00:02:40,256 Once or maybe twice in your game 53 00:02:40,512 --> 00:02:42,560 Maybe you have a Singleton for the player 54 00:02:42,816 --> 00:02:48,960 Maybe you have a single team for something that people called a Game manager which one are actually going to create for this demo 55 00:02:49,728 --> 00:02:53,312 Set another place where you might use the Singleton instance 56 00:02:54,848 --> 00:02:56,896 So we're going in stage you are single 57 00:02:57,408 --> 00:02:59,712 Are we going to do is just go to the 58 00:03:00,224 --> 00:03:03,552 Bottom of a variable seer before start 59 00:03:04,320 --> 00:03:06,368 Let's just make sure we come in today 60 00:03:07,648 --> 00:03:08,416 Singleton 61 00:03:08,928 --> 00:03:12,512 Institution and if this doesn't make sense guys when we start using it 62 00:03:13,024 --> 00:03:14,560 It's going to make a lot of sense 63 00:03:15,584 --> 00:03:16,352 Private 64 00:03:17,120 --> 00:03:17,632 Static 65 00:03:17,888 --> 00:03:23,520 Can you play not gonna get into what static is because honestly we're only reading this line of code 66 00:03:23,776 --> 00:03:29,920 The seriously has just right this code trust me I'm looking at universe documentation right now 67 00:03:30,944 --> 00:03:31,968 Has arrived this 68 00:03:32,480 --> 00:03:33,760 New player instance 69 00:03:34,784 --> 00:03:35,296 Brackets 70 00:03:36,064 --> 00:03:36,576 Get 71 00:03:39,648 --> 00:03:42,464 There we go and then we're going to create a simple condition 72 00:03:42,720 --> 00:03:44,512 If the Instance is nothing 73 00:03:45,024 --> 00:03:46,048 It's no 74 00:03:46,560 --> 00:03:48,864 Instance = game object 75 00:03:49,120 --> 00:03:50,912 That find object of type 76 00:03:52,704 --> 00:03:53,472 New player 77 00:03:58,080 --> 00:04:00,640 NN return instance 78 00:04:02,176 --> 00:04:08,320 Thomas what the heck did you just right and I'm going to be honest with the guys I say this all the time I don't know 79 00:04:08,576 --> 00:04:12,160 But I know what it does and I know when I need to use 80 00:04:12,416 --> 00:04:13,696 And I can't see this enough 81 00:04:13,952 --> 00:04:20,095 As a game developer is not necessarily about understanding every navygrey detail about your code 82 00:04:20,351 --> 00:04:23,423 Understanding what everything means and memorising 83 00:04:23,935 --> 00:04:29,567 Is really about knowing ok there's this thing called singleton's ok and he is a Singleton let's Google that 84 00:04:29,823 --> 00:04:32,383 Now if we're in the apocalypse so we didn't have Google 85 00:04:32,639 --> 00:04:38,783 I would not be a game developer I wouldn't know what the heck I'm doing and I think a lot of Jayne developers wouldn't either 86 00:04:39,295 --> 00:04:40,575 But in this case 87 00:04:40,831 --> 00:04:43,135 Does just know singleton's are used 88 00:04:43,391 --> 00:04:45,439 A single object like a player 89 00:04:45,951 --> 00:04:49,535 Are you going to be referencing all over the place in various scripts 90 00:04:50,303 --> 00:04:53,119 So now we have this line of code that we just wrote 91 00:04:53,887 --> 00:04:56,447 How to reference the new player 92 00:04:56,959 --> 00:04:59,007 Whenever we w ok 93 00:05:00,799 --> 00:05:02,591 What's going to a collectible here in Trail 94 00:05:03,359 --> 00:05:05,151 We don't actually need this anymore 95 00:05:05,919 --> 00:05:06,687 Remove that 96 00:05:07,455 --> 00:05:08,735 We can remove this 97 00:05:09,759 --> 00:05:11,295 But we got a little here here 98 00:05:11,551 --> 00:05:12,575 How do we fix this 99 00:05:13,087 --> 00:05:14,879 Now that we have the Singleton 100 00:05:15,135 --> 00:05:16,159 Would you actually write 101 00:05:16,671 --> 00:05:17,951 New player 102 00:05:18,207 --> 00:05:19,743 Instance 103 00:05:23,071 --> 00:05:27,679 So because we only have one single instance of the player in the entire game 104 00:05:28,447 --> 00:05:31,519 Description girl ok well where can I find that object type 105 00:05:32,031 --> 00:05:32,799 New player 106 00:05:33,055 --> 00:05:34,335 Where to find the Instance 107 00:05:35,103 --> 00:05:36,639 And we're going to do something with it 108 00:05:36,895 --> 00:05:38,175 So we can just literally 109 00:05:38,687 --> 00:05:39,967 Is that all over the place 110 00:05:40,223 --> 00:05:41,759 Get rid of those double dad's there 111 00:05:42,783 --> 00:05:43,551 As well 112 00:05:44,831 --> 00:05:45,599 Say that 113 00:05:47,647 --> 00:05:52,511 I'm your reference at all we didn't need to write anything up here to reference and find that game on 114 00:05:53,279 --> 00:05:55,327 We can do the same thing in the gate to look 115 00:05:56,095 --> 00:06:01,727 Remove all of this Ray and just do you play it at instant start inventory 116 00:06:03,263 --> 00:06:04,543 Even better 117 00:06:04,799 --> 00:06:05,567 Instead of 118 00:06:05,823 --> 00:06:07,871 Game object at nibbles player 119 00:06:08,127 --> 00:06:11,199 What if we just said 8 collision that game Argos 120 00:06:12,223 --> 00:06:12,991 Equals 121 00:06:13,503 --> 00:06:14,527 New player 122 00:06:15,039 --> 00:06:16,063 That instance 123 00:06:16,831 --> 00:06:17,855 That game are checked 124 00:06:20,671 --> 00:06:22,463 Coda cleaner 125 00:06:22,975 --> 00:06:27,327 Actually I like cleaner in the long run because we have a lot of scripts doing this 126 00:06:27,839 --> 00:06:31,167 Does going to Unity in make sure that my instance 127 00:06:32,191 --> 00:06:33,215 Actually works 128 00:06:33,727 --> 00:06:37,055 Now if the code works properly nothing is going to change 129 00:06:41,151 --> 00:06:42,687 Looks like everything works great 130 00:06:44,735 --> 00:06:45,759 Nothing changed 131 00:06:46,271 --> 00:06:47,551 But a lot change 132 00:06:47,807 --> 00:06:49,343 For us as the developer 133 00:06:49,855 --> 00:06:53,951 Because now we don't need to use gameobject that finds I get component blah blah blah 134 00:06:54,719 --> 00:06:56,255 We can do simple use 135 00:06:57,279 --> 00:06:58,303 New player 136 00:06:59,583 --> 00:07:00,351 That instance 137 00:07:01,375 --> 00:07:04,191 And that my friends is the Singleton instantiation 138 00:07:04,447 --> 00:07:07,007 And that's all because we wrote the single line of code up here 139 00:07:08,031 --> 00:07:10,079 Decorated this instance for the new player 140 00:07:10,335 --> 00:07:11,871 And it's weird 141 00:07:12,127 --> 00:07:13,407 I'll be honest it looks weird 142 00:07:14,687 --> 00:07:16,223 Is amazing what you can accomplish 143 00:07:16,479 --> 00:07:20,575 And again guys it's not about understand me every freaking thing about your code 144 00:07:20,831 --> 00:07:22,367 Is that about understanding 145 00:07:22,623 --> 00:07:28,255 How you can memorise all of this code it's about understanding the simplistic terminology 146 00:07:29,535 --> 00:07:33,375 Are you going to remember if there's this thing called a Singleton Thomas was talking about it 147 00:07:33,631 --> 00:07:37,215 What was the my Google it there it is this is the code 148 00:07:37,471 --> 00:07:39,007 How to write a Singleton pattern 149 00:07:39,519 --> 00:07:41,055 How many use that from a player 150 00:07:41,311 --> 00:07:43,615 Or I'm gonna use that for my 151 00:07:43,871 --> 00:07:46,687 Email address which stores you know in Victoria something 152 00:07:47,455 --> 00:07:51,807 That is a Singleton you're going to use it he once or twice in your indie game 153 00:07:52,575 --> 00:07:56,415 And then we'll never going to write this code again guys so I'm not going to memorise it 154 00:07:57,951 --> 00:08:02,559 We need to go into our collectible script and just make sure that now they were using 155 00:08:02,815 --> 00:08:04,607 An instance of new player 156 00:08:05,119 --> 00:08:09,215 We need to make sure that we changed this out as well so instead of checking the name 157 00:08:09,471 --> 00:08:11,263 I don't want to check the gameobject it says 158 00:08:12,287 --> 00:08:13,823 Is collision tag a mate 159 00:08:14,079 --> 00:08:14,591 Equals 160 00:08:14,847 --> 00:08:15,615 New player 161 00:08:16,127 --> 00:08:17,151 The Instance 162 00:08:17,919 --> 00:08:18,431 Game on 12214

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