Hi when im reloding and i unequipe the gun it calls to stop the couritine
if (Input.GetKeyDown (KeyCode.R)) {
StartCoroutine("Reload");
}
IEnumerator Reload()
{
if (reloading == false){
reloading = true;
canFire = false;
GetComponent<AudioSource> ().PlayOneShot (graphicsAndSounds.Reloads);
yield return new WaitForSeconds (weaponStats.reloadTime);
for (int i = 0; i < inven.Items.Count; i++) {
if (inven.Items *.itemType == Item.ItemType.Ammo) {*
_ if (inven.Items .ammoType == inven.Items [slotNumber].ammoType) {_
* int ammoToTake = weaponStats.ClipSize - weaponStats.CurrentAmmo;*
* if (weaponStats.CurrentAmmo < weaponStats.ClipSize) {*
_ if (ammoToTake > inven.Items .itemValue) {
ammoToTake = inven.Items .itemValue;
* }
weaponhandler.Weapons[weaponhandler.whatGun].WeaponModel.GetComponent().weaponStats.CurrentAmmo += ammoToTake;
inven.Items .itemValue -= ammoToTake;
}
}
}
}
reloading = false;
canFire = true;
}*_
* }*
but the problem is when i equipped the gun again i can no longer fire as the couritine stopped half way through and canfire has not been set to true again. ive tried setting canfire to true when i equippe/unqeuippe it but the couruitine seam to take priority and keeps switching it off what can i do to stop this?