I am making a first person shooter game in unity. I have a bar on the top of the screen that is equal to the number of bullets in the gun. Problem is, When I shoot a bullet, I want the bar to decrease = to the number of bullets shot. I have a decreasing animation that works perfectly. I need to do something like this.
When I shoot the gun, play animation. If Im not shooting, stop animation. If im shooting play animation where it left off.
`
// Checks every frame
void Update ()
{
// Display how much ammo is remaining
text.text = "" + Ammo;
// If the user has pressed spacebar and there are bullets inside the gun,
if(Input.GetKey("space") && Ammo >= 1)
{
// Subtract the ammo
Ammo = Ammo - 1;
// Play reload stop
anim.Play("ReloadStop");
}
// If user is not shooting the gun,
else
{
// Stop the animation
anim.Stop("ReloadStop");
}
`
Also, why is my Update function not inside the ?