Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Now, in this video, you want to be able to get these enemies to respond, even if they attack you.
So in our scripts, obviously we've got our damage, but we've also got our main need, the two scripts
to talk together.
So what we got Aspelin points.
We need to change our public into zombies on screen to a public static so that it can be accessed by
other scripts.
Public static is one is a variable that gets saved in RAM in actual memory on your computer.
And so exists outside of any one script.
And that's good.
It can certainly save it between between levels and all sorts of stuff.
In a way, it's good, but in a way it's also bad as well, because you do have to reset them.
You have to remember to do that.
We'll get into that later.
OK, public static game objects as well, so we can access these from the other script.
So we've got public static zombies on screen, Butson screen, Gelson screen and make these public not
private, sorry, public, static.
Otherwise they won't be available.
Public static game objects of lust destroy zombie last destroy Bakhtin.
Last destroyed ghost.
OK, now over in our damage, you can say if the other object is just this, this is a bat and we can
say main dart bats on screen is minus minus.
We can also say may dart and blast destroyed.
Bat equals the dart game object.
So the dart.
Game object.
There we go.
So that will then place that into that slot.
OK, so let's just that let's take all this control.
See, let's do the same on Ghost and just change this to last destroyed ghost and ghosts on screen.
Let's do the same for zombies as well.
Last destroyed some bee and some bees on screen.
Now, that should get some response.
Let's just double check this to make sure that this works.
So why wait for some of these creatures to actually hit my character, who was born in different points
throughout the game world?
So I'm constantly asking me.
Good.
All right, that's working.
But now we need to get these images to actually turn on.
So for this back in the main, you know, give myself a comment.
So let's call it player damage.
We need a few more variables.
So first of all, we need some kind of a ball.
So I'm going to once again make this a public static so it can be called from the other script of type
boolean or call zombie attack equal to false to begin with.
No, we need one for the bat and the ghost as well.
Control and see, control and B, control.
The schools say ghost attack and bat attack.
That means that now I can save this, go into my damage and I can say main darts and which ones less
but sohbat attack equals true.
So I know that I've just been attacked by Abbott control and C, control and B, control.
And they say that this one is a ghost attack and this one is a zombie attack.
So now that I know I'm being attacked, what we want to do inside of the update and we do need to do
it in the update, unfortunately, because it could be happening on any frame.
And if it's after one second, it's probably just too late.
So I'm going to leave myself a comment and this is going to be damage visuals.
So I'm going to say, if zombie attack is equal to true, then in that case, we instantly want to switch
it off.
So zombie attack essentials, it only runs on one prank equals false.
And then we need access to images, OK, which I haven't put in yet.
So public health type images, I don't believe that we've done any UI elements yet.
So using unity engine dot UI, that's going to give us access to things like images and buttons and
those kind of things.
Now, I can say public of type, image and core.
Fact, I don't need it to be an image of just it's a game object.
Probably easier that way.
So actually, I can take you I will put it back later.
Public game object I call zombie graphic.
Let's call it.
Uh, so I mean, the updates and I'm going to say zombie graphic.
Don said active to trip.
OK, going to switch that up and then we do have to switch it back off again so we can start a routine
and I will call zombie off.
Now, I do need some time, so I'm going to create a new wait for second soapier.
Wait for seconds.
I'll call it graphic.
Pause.
And then that's going to equal a new wait for seconds.
It's going to equal about zero point three.
All right.
Not very long at all.
So now I can create my zombie off.
I'll go right down to the bottom.
Do it down here.
I enumerator zombie off.
Can't remember if it was capital Z or not.
Soon find out
it's turned yellow, so it must be correct, then it's a yield turn.
And it was professor.
Pause.
There we go.
Excellent.
So now we can simply switch off zombie graphic.
So some epigraphic don't sell out to Fox, switches it off again after zero point three.
OK, so we now update.
Oh, it was a lowercase C, so it just changed up to an uppercase if zombie attack is equal to true.
Let's do the same with other ones.
So control Z, control V, control V.
And I'm going to do if that attack and if ghost attack.
Switch them both off immediately.
And so we can actually.
And if you like, optimize things instead of calling Separate Coroutine, you can actually call the
exact same currency.
But on these ones, we just simply switch off different graphics.
So we've got our zombie graphic.
We now need our public game objects of.
But graphic and public game objects of ghost graphic.
So all we have to do here is take our back graphics, which are done, ghost graphics which are done,
and as soon as we've done that, we will run this same coroutine.
So after zero point three seconds, we simply switch them all control and see saves up and to call numerous
our enumerators.
So then we can say that graphic and ghost graphic.
Switch them all off.
OK.
That's it.
All right, so let's now check if you've got any empty slots we should do.
So we have a zombie graphic, but graphic and ghost graphic.
Let's test this now, so let's play and wait for these characters to actually attack the player.
OK, great.
Yep, so that coming up, I think zero point three should be fine.
Normally you're not going to be getting attacked that fast, and at least not until later levels.
So we'll sort that out later.
What we'll do in the next video is actually get a health bar so you can actually preview our much health
you have left.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.