- Home /
Weapon swap help
well, i can switch guns between all the prefabs that i got attached to the script, but when i switch, the guns are fully charged everytime i select one
for (int i = 0; 0 < guns.Length; i ++)
{
if(Input.GetKeyDown((i + 1) + "") || Input.GetKeyDown("[" + (i + 1) + "]"))
{
EquipGun(i);
break;
}
}
}
void EquipGun(int i) {
if (currentGun) {
Destroy(currentGun.gameObject);
}
currentGun = Instantiate(guns[i],handHold.position,handHold.rotation) as Gun;
currentGun.transform.parent = handHold;
currentGun.gui = gui;
animator.SetFloat("Weapon ID",currentGun.gunID);
}
how can i make that the guns conserve the ammunition when i switch to others?
excuse my english
Answer by Bovine · Mar 18, 2014 at 08:47 PM
What determines whether a gun is 'fully charged?' is it the value of some ammo field on a script attached to the gun?
You are destroying the guns each time you swap between them. It may be better to have all the guns attached and to just hide the ones not in use.
yes, by fully charged i mean full ammo, would you help me how to make that hiding stuff? just how to start
Your answer
Follow this Question
Related Questions
Weapon pick up and switching script 2 Answers
Weapon Switching 1 Answer
Changing enum values 1 Answer
Accessing local system ( File Browser ) 2 Answers
FPS Switching Weapons on iPhone 1 Answer