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 we want some way to actually see what this damage is doing to our character.
So in the mobile game resources, you'll find a graphic health bar just going to add this to our canvas.
Just right click Jujuy and new image drag elfa into the source image and click certain ATSIC.
This one is not a rakas target because we don't need to interact with it.
But instead of its image type being simple, we're going to make this one filled image and to change
its fill method to horizontal.
And you'll now see that the full amount can be regulated.
I actually want it to go from the right instead.
OK, so it can go can do this and we can actually manipulate this in the code by using this fill amount
variable.
OK, first of all, I just need to position this somewhere on the screen.
So I'm going to choose the top.
Right.
And it's not an item that we need to click on.
However, I still recommend that you change type just to see where it is on all the different pieces.
As you can see there, it's basically been excluded.
Well, I want to make sure that it is targeted to the top right.
And then I simply just want to drag this over a little bit until it fits nicely in the corner.
We get that as close as I can to the corner and then that way on other systems.
It shouldn't be too far away from the edge.
Now, as you can see there on the Apple iPhone, and it's being cut off.
So I just need to check it on each of the devices.
Yeah, that's OK.
It's perfectly fine.
Feel free to go through absolutely every one of them, but I should imagine at the moment this is pretty
good.
It's a really long film.
Right.
OK, so it looks fine on all of them.
Great, I'll just go back to Samsung Galaxy J7.
That's that's one that kind of looks very generic.
Excellent.
OK, so let's change the name of this to help.
Whenever we want to access, for example, in the components that are on a UI element in the script,
we do need to tell it that we are accessing UI.
So if we go back into the main script right at the top, we do now need to say using unity engine dot
UI.
Not way I get access to that image, OK, so I'll just leave myself in another comment.
So health bar.
So this is going to be a public health type image for health bar.
In fact, it doesn't need the capital be there, so just one word health bar, OK, and then I need
some kind of a damage amount.
It's going to take place each time.
One of the animals hit me, it's me.
So I'll make that a public float.
Old damage amount's.
I'll probably make that about zero point zero five.
Now, it's right at the moment.
It does need an F on the end, and the actual fill amount only goes between zero and one.
So if you got a value greater than one, that will instantly be filled.
So when when you're talking about taking damage off there, it has to be a value less than zero zero.
If it's really small, so it's only going to take it off by increments.
And that's exactly what I want.
OK.
Which is why it's so small.
If you do all the different damage amount, let's say, for a ghost or a bat or a zombie, you could
create three different damage amounts if you want.
And where we have our update and we've seen if zombie attack is equal to true and we're simply going
to take it and the health bar off from here, so we're going to say healthcare, don't fill them out.
Minus equals damage amount.
That's it.
It's quite easy.
Let's do that also for the other ones.
Some control C, control V and control the OK.
And that will then start to take the alpha.
So some of the length of the health bar until it reaches zero.
OK, so we're going to see the player getting damaged.
Let's click on ground.
We do need to assign this image health bar.
Now we can try this out.
OK, so we don't let these creatures talk me.
There we go, can see the alsp really going down now.
Right.
These creatures are too far together.
And don't worry, we're going to be sorting that later.
Definitely the health bar is now going down.
And when it gets to zero, we actually want some kind of a game over.
You've sort of lost.
So to do that, I'm going to go all the way down to the bottom.
Well, I have the time delay, and I'm going to do instead of for enemies, I'm going to do check for
Gameover.
It's going to be a custom function, so I'll create that now just above for enemies may be able to avoid
check for came over.
OK, and all I'm going to say is if Health Healthpoint don't fill amount.
Is less than or equal to zero.
That's the case, and at the moment, all I'm going to do is basically display a message Debord debunked
log game over.
Later, we'll add some functionality so that you can basically be turned back to the menu.
OK, and that's how you get a health bar working in your game.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.