OK, so we've got our weapons switching, working visually, but of course, the moments that doesn't
actually do anything for our game, if we go and play, I can shoot with this guy and I can Ottavio
my pistol.
I can order fire with all these and there's no difference between them effectively.
So we need to change that.
And it's got to be very simple to do.
All we have to do is go into our player controller script and if we scroll all the way down to the bottom
to our shoot function, we're going to replace any areas where we're using the default values that we
have before.
I see a really simple way to do that is to go back up to the top here.
And for example, we want to use the time between shots from our gun.
So if I come at this out by putting two little slashes in front of it, that means this is no longer
working correctly then in our.
Max, he's under huge pressure.
Here we go.
We don't want to use the heat pressure anymore, so I'm going to come this how you can comment something
else in the middle of an area.
We don't want to accommodate the whole line like that.
So when you comment about something, it means that it won't read as code that we can actually use.
So instead, I'm going to go here before my heat pressure.
I'm going to write slash star, slash star.
There we go.
So slash, I will basically say, hey, everything after this point.
Ignore until you get to star slash.
So I'm removing the heat pressure out here.
It's important to note that we only have one comma in between Maxi's and Cool right here or else you'll
have a little air.
So what we'll do from that point then is say, oh, OK, we've removed both of those because we want
those to happen from our gun over here.
And then what we're going to do is we're going to scroll down to where we find any errors now I have
this thing set up in my visual studio where I can see where the errors are.
But if you just have a normal scrollbar, if you scroll down to your project and keep an eye on the
left hand side over here, you'll notice some different colors.
You'll see is a yellow here where we've made any unsaved changes to our scripts.
Anywhere that is green is telling you, hey, this is somewhere that you've made a change since this
file has been opened.
So this is something that we've made a change to, but we've saved that change.
And if we scroll all the way down here, well, I thought it was a red mark in the bar over here.
I think maybe that's another extension or something like that, which I'm not using.
But more importantly, you see these red underlines over anything, under anything.
And the reason this red underline here is here is because obviously there is no time between shots anymore
value up top.
So what we're going to use instead of time between shots is from our all guns array at position selected
gun within that gun that we're referencing.
Get the time between shots value from this script over here.
So we'll do the same for our he's precious to say, all guns, apposition, selected gun that he's purchased.
And one final thing we're going to do is if we go back to a gun, we know we have an is automatic check
here.
So let's go up to our player controller and where we are handling our shooting, which is over here.
Here is where we press our shoot down the first time, and that's fine.
And then here is where if we hold the button down, we continue shooting.
So we're only going to be allowed to continue shooting if we are holding the button down and.
All guns at position, selected gun that is automatic, so as long as there is an automatic weapon,
we're allowed to continue firing.
OK, so there's a very simple little changes, let's jump back into unity, once it compiles, Will
should be able to see when I press play.
Now I can fire a shot, even if I no matter how long I hold it down, it won't alter fire.
And you can see at temperature meter in the bottom right is filling up a faster.
Let's switch to my pistol.
There we go.
We can shoot like we want to.
And finally, the rifle.
It'll very quickly fill up our meter and it does a lot slower, but still does our auto firing situation
so perfect now our weapons are switchable and they work correctly.