Hey Everyone, i’m going to Remaster the unity & Utech Angrybots and turn it into my game, i added inventory, health bar, main and pause menu, even save game, but when i want to make the gun to not shoot when out of ammo, i cant do that .please help.
2 Answers
2if(ammo > 0)
{
shoot();
}
First you need to make a variable which tells how many ammo you have. Then, you need to subtract 1 from the ammo for each time the player clicks. Soon, the ammo will run down to 0. Then, you need to add a line of script that makes the player unable to shoot when the ammo is 0. So it means that the player can only shoot when the ammo is more than 0.
if (Input.GetButtonDown("Fire1")) {
if (ammo > 0) {
Shoot ();
ammo --;
}
}
Something like that. And Hope this will solve your problem. Cheers!!!
i used theese, but i mean in the angrybots i cant find where is the shoot function comes from
– anon54740437well, you need to search through their script. Try to find what makes the player shoot. Then, get those line of code that you found and put it in the if (ammo > 0 )
– henry96