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 do have a reload animation for our gun.
The moment we never run out of bullets.
So in this video, we're going to create a finite amount of bullets before you have to reload.
OK, so the first thing that we need is a reload button.
So we've got our shoot button when the duplicate that control and D and just moved up up above the shoot
button.
And I want this one to simply be a reload, so let me just change the text to say reload all in capitals
again.
I don't want this one to be read or for it to kind of be a big circle.
So what I'm going to do is I'm going to go back to my joystick pack sprites, and we do have some horizontal
ones.
I quite like.
So for this, I'm going to choose the horizontal riched.
OK, and just make that a little bit bigger on the width and just a little bit bigger on the height,
you know?
No, I don't want it to be read.
I want this one to be orange.
So when you take this code troll and see it, you also put it on the selected code, control the movie,
and then when you reload, I'm just simply going to turn this white breast also on white.
And yeah, I think I think that's OK, if you want to go with one of the other ones, that's perfectly
fine, OK, but I think they should be OK.
So that's my reload button.
So let me just name it that.
Just get that one on the end.
At the moment, it's running this function, we're going to change this in a second.
But I also have some bullets as well, graphics of bullets.
Here we go.
Small bullet.
So what I want to do there is on the canvas, just right click UI and a new image, drag the small bullet
into the sprite set.
Neat size.
There we go.
We've got the bullet.
This is not a rakas target.
It's just a simple image.
And I'm going to drag it down to the bottom and then over here to the right.
So basically to be very near to the shoot button.
Wondering if that bullet is a little bit vague, actually, and might actually just reduce scale down
to zero point eight on X, Y and Z.
Not looks a little bit better.
All right, so this is bullet.
In fact, what I'm going to do here is on the canvas, just right click and choose, create empty.
I'll simply call bullets so we can keep all these objects together.
Let's just take the bullet and put it onto bullets.
So that is then a folder.
And uh, now I can duplicate this.
Some control in D.
And then I want to move this over to the left.
What I want to do is find out exactly what is the difference between bullet one bullet to see if that's
400.
This one's 368.
Let's make it maybe three seventy.
That looks pretty good.
There's a difference of 30 between those two.
All right, that's that ensures that I can have a consistency between my bullets.
So this one is bullet to.
Control and control, and they still got four, five, six, seven, eight and planning of eight bullets
in the magazine.
So if this one is 370, we've got reduced 30.
So 340 notes, so it lines up nicely.
So 310.
And 280 lines up nicely.
250.
To 20.
And then finally, 190, OK, notice how they're all nicely lined up with each other as well.
Great.
So let's just rename these three.
It's not necessary to rename them, to be honest, but just for the sake of it being easy to read.
Certainly if you come back to a project after a long time and you're thinking, OK, well, what's going
on here?
It's always best to have things organized nicely.
And it's really, really easy to understand.
Bear in mind, it finishes about seven.
The first one didn't have no.
Oh, no, it should be eight.
Actually, the first one should have been bullet one.
There we go.
All right.
Excellent.
So now back in the script, what we want to do is
we want to apply these to our scripts.
You can leave Mossop comment and this is going to be reloading.
OK, and we need access to that reload button.
So public after game object, we'll call reload button.
Then we need a bullet count.
So private integer or bullet counts equals eight, since, you know, we've got eight bullets.
And then we need to be able to drag all of those bullets into our script.
So public game objects will call.
Well, at one.
Just copy this drone C control V three, four, five, six, seven, eight.
Two, three, four.
Five, six, seven and eight.
OK.
We also need some kind of a wait four seconds and which is going to wait until we've actually played
our reload animation before it actually refills the bullets.
So we're going to have a wait four seconds.
I'm going to call it and reload.
Pause equals a new.
Wait a second.
And it's going to be roughly about three seconds.
OK, so now in a shoot, we want to make sure that you can only shoot as long as you've actually got
some bullets in your gun.
So just underneath the fire, we're going to see if bullet count.
Is greater than zero.
And we're going to contain all of this.
Inside of that bullet count, OK, if you hover over these, it will actually show you what the connecting
and curly bracket is, and that looks fine to me.
OK.
Each time that we fire and we want to say bullet count minus minus.
So we're reducing that amount of bullets.
And then we're going to run a custom function called display bullets.
The reason why these custom functions is simply so I if I've got a function, I don't want to write
too much in the function because it becomes harder to read.
So by having all of these separate custom functions, it just it makes it easier to read and it's easier
to layout.
So I'll do it on their.
This actually should be avoided display bullets.
He's simply going to say if bullet count is equal to eight, and that means we've got all bullets.
So we need to ensure that they're all switched on.
So the same bullet can't set active.
Oh, it's bullet count.
It should be bullet.
Now check out what they've done there.
Oh, yes, Bullett.
Well, now I put a number on it.
Bullet one set active.
Too true.
So which, you know, it's the same with all the others control and see from the three, four, five,
six, seven, eight.
OK, there we go, and then we're going to say, if bullet count is equal to seven.
Instead of having to write all love again or we're gonna do is switch off bullet eight because you've
used one.
So we're going to say bullet eight seductive to switch it off.
Let's copy this drone C drone base now.
Six, five, four, three, two, one case.
It'll be the safe bullet count is equal to six.
We're going to switch off bullet seven.
Well, it counts as equal to five.
Going to switch off bullets six.
If it's four, when the switch of bullet, five if it's three, then switch off bullet four.
It's two.
We're going to switch off bullet three.
And if it's one, we're going to switch off bullet two and then need another one on the bottom.
For one, we've run out of bullets.
OK.
Bullet count is equal to zero.
I'm going to switch off bullet one.
And we need to switch on our reload button.
So reload button.
So seductive to true.
OK, so that will then display all of our bullets, which is good.
All we need to do now is basically call a reload function from our reload button so we can do so by
saying public void, let's call it reload.
OK, so the first thing that we need to do is access the bombs and then to set trigger.
Let me just double check what we actually called this.
So just wait for that to date.
So in the animator, we called it reload with a capital R.
OK, so we're going to set up trigger reload.
OK, and then as soon as it's done that we're going to basically started Gorriti because we need to
either pause more, call it and wait for reload.
And then as soon as we've done that, we want to switch off the reload button.
Seductive to false.
Safer so now down in I enumerators bottom.
I enumerator wait for reloj.
This is then going to call a ealt return.
And we called it and it reload porc and we go, that's going to wait three seconds and then it's going
to set a bullet count back to eight.
We also need to ensure that we're displaying bullets and display bullets.
That's what we called it.
If you don't call up, you won't get the bullets appear on screen until you actually shoot again.
So we have to call that function so it can run through it and basically switch everything back on the
gun.
It's safe that that should work fine now.
So all we need to do is attach bullets to a script.
So on the ground now of a whole bunch of empty game object, so we've got a reload button distracted
by default, reload button is going to be switched off.
And then we need bullets.
Well, at one point, two, three.
For.
Five.
Just make sure you're going into the correct slots.
OK, there we go.
So let's just save this and check this out.
Now, each time I shoot, get rid of a bullet.
OK, and then as soon as I've gone through all of those, you notice I can shoot, but it won't be it
in anything until I press reload.
Oh, some reason it's not reload and bullets.
Oh, I know why I didn't.
I mean, the relo button, I didn't put anything on the script.
I just had the main chute.
So on the main, I'm going to choose reload.
I have to call the correct function.
OK, let's try it again.
Shoot, shoot, shoot, shoot, shoot.
OK, and then reload the bullets back and off we go again.
Excellent.
OK, good.
So what will work in the next video is just given, not reload sound.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.