Hey guys, im making my ammo system like warz, if you reload , you drop the ammo, and I saw that when I have no ammo it keeps reloading, here is the code, i want to munition = 0 , bullets = 0 cant reload
if (Input.GetKeyDown (KeyCode.R)) {
if (munition > 0)
munition--;
if (amountBullets <= initBullets) {
amountBullets = 0;
amountBullets += initBullets;
Can you get away with just modifying your if statement?
if (Input.GetKeyDown (KeyCode.R) !(munition == 0 amountBullets == 0))
EDIT: Fixed. Now it reads if player does not have both munition == 0 and amountBullets == 0.
the problem was solved, but only when I have only 0 and 0 bullets combs, when I reload with bullets remains the same
What do you want to happen if munition is zero, but amountBullets > 0? Should the reload be ignored or will the player drop their currently loaded ammo?
if (Input.GetKeyDown (KeyCode.R)) {
// Only reload if the player has less than a full clip
// and has munition available.
if (munition > 0 amountBullets < initBullets) {
munition--;
amountBullets = initBullets;
}
// Drop loaded ammo if no munition available
else if (munition == 0) {
amountBullets = 0;
}
}