All language subtitles for lesson098

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

Original subtitles

Alright so some of you then probably wondering

Thomas why are you not using the Singleton pattern

Now some of you are thinking what the heck is a Singleton pattern

Well let's jump into you

Are collectible script here

Take a look at something

We have a new player variable to that we actually have a reference to the new player component

Welsh Everytime We create a script correctly

We have to create a new reference

To the new player

Frustrating

We do that again as well so

A magical find player that getcomponent new player

This is redundancy in Multiple scripts

It's kind of annoying

If we had an enemy scratch

We also have to write this out in that

If we had an NPC script

Subtitled by -♪ online-courses.club ♪- We compress knowledge for you! https://t.me/joinchat/ailxpXoW3JVjYzQ1

We have to write it out there

We been writing it out probably 100 to 200 times for a final game and I can actually admit that

Striped my very first game

Does this

The alternative is to use something called a Singleton

A Singleton basically refers to a game object that is easily reachable from

Anywhere in there only exists one of these

At any given time to have more or less than one of these game objects

Set a player game object with the new player component

Is actually a Prayer example

Have a Singleton

Because it's only ever one thing in the entire game

You never going to have multiple players

Right

So if I want any script that I create

To be able to reference this player

Whenever I want without requiring me right out this

Horrible

Line of code gameobject find player that pony

If I want to avoid writing this all the time

Then what I need to do

Is simply

Make this new player

A Singleton instance

It sounds confusing

The words are kind of strange

And when you look at the code it's going to be even stranger and trust me and strange to me too

Actually haven't even memorise this code and the reason I haven't memorised it is

Well to Singleton you only use it once you write this code once

Any allows you to do so much

For your entire game

Oh really you're probably only going to write this line of code that were about 2

Once or maybe twice in your game

Maybe you have a Singleton for the player

Maybe you have a single team for something that people called a Game manager which one are actually going to create for this demo

Set another place where you might use the Singleton instance

So we're going in stage you are single

Are we going to do is just go to the

Bottom of a variable seer before start

Let's just make sure we come in today

Singleton

Institution and if this doesn't make sense guys when we start using it

It's going to make a lot of sense

Private

Static

Can you play not gonna get into what static is because honestly we're only reading this line of code

The seriously has just right this code trust me I'm looking at universe documentation right now

Has arrived this

New player instance

Brackets

Get

There we go and then we're going to create a simple condition

If the Instance is nothing

It's no

Instance = game object

That find object of type

New player

NN return instance

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

But I know what it does and I know when I need to use

And I can't see this enough

As a game developer is not necessarily about understanding every navygrey detail about your code

Understanding what everything means and memorising

Is really about knowing ok there's this thing called singleton's ok and he is a Singleton let's Google that

Now if we're in the apocalypse so we didn't have Google

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

But in this case

Does just know singleton's are used

A single object like a player

Are you going to be referencing all over the place in various scripts

So now we have this line of code that we just wrote

How to reference the new player

Whenever we w ok

What's going to a collectible here in Trail

We don't actually need this anymore

Remove that

We can remove this

But we got a little here here

How do we fix this

Now that we have the Singleton

Would you actually write

New player

Instance

So because we only have one single instance of the player in the entire game

Description girl ok well where can I find that object type

New player

Where to find the Instance

And we're going to do something with it

So we can just literally

Is that all over the place

Get rid of those double dad's there

As well

Say that

I'm your reference at all we didn't need to write anything up here to reference and find that game on

We can do the same thing in the gate to look

Remove all of this Ray and just do you play it at instant start inventory

Even better

Instead of

Game object at nibbles player

What if we just said 8 collision that game Argos

Equals

New player

That instance

That game are checked

Coda cleaner

Actually I like cleaner in the long run because we have a lot of scripts doing this

Does going to Unity in make sure that my instance

Actually works

Now if the code works properly nothing is going to change

Looks like everything works great

Nothing changed

But a lot change

For us as the developer

Because now we don't need to use gameobject that finds I get component blah blah blah

We can do simple use

New player

That instance

And that my friends is the Singleton instantiation

And that's all because we wrote the single line of code up here

Decorated this instance for the new player

And it's weird

I'll be honest it looks weird

Is amazing what you can accomplish

And again guys it's not about understand me every freaking thing about your code

Is that about understanding

How you can memorise all of this code it's about understanding the simplistic terminology

Are you going to remember if there's this thing called a Singleton Thomas was talking about it

What was the my Google it there it is this is the code

How to write a Singleton pattern

How many use that from a player

Or I'm gonna use that for my

Email address which stores you know in Victoria something

That is a Singleton you're going to use it he once or twice in your indie game

And then we'll never going to write this code again guys so I'm not going to memorise it

We need to go into our collectible script and just make sure that now they were using

An instance of new player

We need to make sure that we changed this out as well so instead of checking the name

I don't want to check the gameobject it says

Is collision tag a mate

Equals

New player

The Instance

Game on

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