All language subtitles for lesson078

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

What if I wanted the player to get hurt

Whenever they touched the edges of this frame

Maybe you know we could put spikes

On the edges of the frame

Are maybe they were enemies

That were on the edge of the frame

What the weather we would do this is actually

Just add another command

Inside of this condition

So we could say

What's a health

- equals

1

What about

Here as well

Health - = 1

Ok

Here as well

Health

- = 1

And then health

- = 1

So we have

Each condition

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

Setting the transform value in also

Removing the hair

The one on Saturday

Maybe debug.log let's say

Hurt

And then

Plus what the actual health is so they're going to display

That I was hurt and and also what my health is

What skimmia Rubella maybe put a calling innerspace

And we can put that there

Here

And then was so pretty

Hear it

Ok let's go into unity

To get your health is currently set to 25

Play here and see what happens

I got the right I should get her

There we go

So now I helped is negative 191 so were certainly already dead that happened pretty fast

And you can see that it's actually displaying

What are hurt value or a health is as we had

The what

What about the top

Yeah

At the bottom here was clear

Play at the console

Just so we can see it clearly

My health is going down but for some reason it's not

Displaying in the console

Why is that

Well

When you're writing a script

Sometimes you're going to forget

Include

Certain parts in each condition

I can be a real pain in there is how we basically have a lot of redundancy here and redundancy is essentially

The same line of code

Over and over again

What we can actually put this all in one place

Search delete this

This

This

Copy this really quick so there's just can't be there

And let's see here let's go all the way past the update

What's clean this up to

So this is a function right here ok

Update is a function

In a function

Is usually started with these little curly brackets select really break

You can follow the dotted line all the way down

To its closing bracket

Not if you click next to it

I doubt you'll see it's highlighted blue

You can see where it's closed with the other highlighted

So that's a closed function

So we can start a new function

What we can do is type void and we'll talk about what a boy means in a second

Boys

Hurt

We can just pray and name in this case it's called her

Printer sees

Open it up

And now we have a new

Function

Pasting those values

So now we can actually use this function

Over and over again

The thing

Anytime you create a custom function like this

It only runs

When you tell it to

So this update function here

This runs all the time

Unity wall run this over and over and over again like we discussed in the previous tutorial videos

A custom function like this

You can tell us customer because of the green or yellow text your account looks like puke yellow doesn't it

That is a custom function if it's only going to run

When we tell her to

So

We save it and hit play

You noticed that nothing gets printed in the console window

That function exists we just haven't used it

It never occurred

Because we haven't told you need to use

We've created the function it exists

Basically a weapon or a tool that we have available to us

We haven't used it

Cell

Are we going to do is simply

Put it

Here

So what this means is

Call the function

Hurt

Another way of putting it instead of using the word call it's basically saying perform the function

So if my transformed value is greater than 8.35 in the x axis

Natalie am I going to

Put the X value 8.3 f

I'm also going to call the heart function

Which is going to track my health

And also

Print to the console window

We can put this in

3

All four of my conditions

What's a play and make sure it works

There we go

So we're getting

The health printed

And also

Our health is actually subtracting over here

Very

So you noticed that

Everytime I touch

The right side of the screen my health goes down

Which is

Kind of really unfair the player because they didn't really

Wanna get heard damn many times they were really warned were they

Well we can actually just create a counter

Allows them to recover a little

So basically what we want is if I'm on the right side of the screen I want to get hurt

Wait 2 seconds her again wait 2 seconds her again wait 2 seconds hurt again

The way that we can do that is put this all inside

After her function

Sebastian four conditions

Aka statements

Inside of actual functions

So here's what we can do

If that's right it on pseudocode if my recovery counter

Is smaller than 2

It's a greater than 2

Then I can get hurt otherwise and else

I won't I will be invincible

Alright so

Does recovery counter exist

Meaning does this variable recovery counter

Does that exist

It is not so we need to declare it or another way of putting it is we need to birth it

Don't actually just burp the recovery counter appear it doesn't need to be serialised and it doesn't

Be public or private video call it recovery

Show me spell it right make sure we declare what it actually is it the private flow

Bounce by default 0 so we don't need an equals sign

Alright

So what will do is will say

If

Recovery counter

Is greater than 2

I can get hurt

What's going on why do we have a red squiggly line underneath this closing bracket what it's because

Missing an opening bracket somewhere where is that

Well below every condition and also blow every function you need to make sure you're opening up that statement

With an opening bracket so do that

Here

What's I get me two of them

Visual Studio deliver computers that's ok what does backspace in now everything's fixed

So if a recovery counter is greater than 2 then we can actually get her

Otherwise it's not going to do anything and I can get hurting when I get to print anything to the console window so

Save it out here and

What's go ahead in actually serialise this field just so we can see what's happening inside of the unity editor

Temporary serialisation

So

There is a recovery county down here that supply and see what happens

Nothing is happening

Well this is in a bank this is actually because well we just didn't finish our code

We need the recovery counter

To iterate up towards to

So we need to write that in code

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

So where we ride the iteration

Would it happen here

Well if it happens inside of here

That means that every time we get hurt the recovery counter will go up and we don't want that we want it to constantly

Counting with actually put

Somewhere inside of the update

Cell

When are we just read it you'll a threesome pseudocode

Increase increase increase increase

Recovery counter

Wine

Per second recovery counter you can do it this way recovery

Equals recovery counter + 1 x x

That's mass great it's still gonna work was cleaning up a little bit so as to

+ = number + = basically means equals

Recovery cancer Plus

A number

So plus

Equals South recovery counter increases by 1 x x x

What's the time 12 what's 1 x x at delta time was actually just time

Member any value x x 1 is the same thing so

Increase

Bye time that there was a time so really it's just a counter just like a watch

Is always going to be iterating and increasing the value of 1 per second

Again this recovery counters always going to be taking up word

Air for greater than 2

Where they decrease the health

Does saving out here

Go back to Unity and hopefully

Take a look at a recovery counter

Ok so it's it's over 2 so that means I'm

Capable of getting hurt

But I'm getting hurt

Why on earth

Can I still get hurt so quickly what it's because a recovery counter is still over 2 and never goes back

20 so are we going to do

Is

Set recovery cancer

0

When we get hurt

So let's try it now

Recovery garages at 2

I get hurt there Goes Again

Hurt

Hurt

Hurt

So you can see we have

The ability to recover every time we get hurt

And this is just classic with any arcade game you give the player a little bit of wiggle room so they

Get out of whatever situation they're in recover and then re engage

In the reason I showed you this guys is not necessary to show you what every arcade game should have

Bye

What you can do inside of a function

In this case it's the function hurt

Can you imagine if I had all of this

Pasting here paste of here

Play say here pasted here

Natalie is it incredibly messy and basically double the length

The Script

If I wanted to change anything about what happens when I get hurt less they want to do

Maybe

Get hurt by value 5 instead of 1 I have to change that value

Four different times

And that is a pain what I wanted the recovery calendar to be 3

And you know if you forget to do one

Condition down here

And then you have play you go wondering why are some moments when I get hurt

Along with another ones

What's going on and that's why you want it all to be clean and in a single function

The bottom here

Now how do you know when you should use a function

Well if you're ever riding the same line of code more than once

Use it in a function

That's a good rule of thumb

You might wonder what time is

Why did you put this

Multiple times

Well

Actually separate lines of code because we have negative positive in a Nissan X value ship where

Better y values

Now there's certainly ways that we could clean this up these conditions you could actually use some clever

Off the probably bring this all down into one conditional statement

But for the purposes of this tutorial I think this is totally fine if we didn't want all of this

Inside of the update function for everyone to keep you updated function really clean

What would you could do if you could do void check boundaries

Just paste all out in there

And then I had a new is we can type our

Here and then just type check boundaries

Is it boundaries having that's what it is yeah it's with an a

So we can have a function called check boundary survey in so now you know that it is ever in issue

Boundaries instead of digging around in the update for it you can actually just go down to the function

Can you give me and I'll make your functions alphabetical

So instead of

Check boundaries being below age

You can copy and paste it above age

So that you can easily sort through all of your functions in remember guys functions only happen

Can you tell unity to do them

Ok

Now it's cool here is that

Check boundaries is happening all the time because it's inside of the update

Constantly updating sore constantly checking the boundaries

Well inside a check boundaries we have the heart function

So what using functions inside a function which is really cool in it clean things up and makes things

Manageable now I understand that this might be a little bit confusing like nesting dolls right

What are the recommended follow along with me

Wiki the super simple 2D game kit and as we practise as we create this game Kit it's

Become second nature for you

So don't worry if it doesn't make much sense but we're going to keep doing these kinds of logic

Over and over and over again

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