So this script should switch through magazines, not fill a magazine. What happens is with the first reload, even tho' the animation happens and everything. The magazine doesn't change until after you shoot and then reload. Reloading again will switch between 2 out of 4 magazines even if the 2 are empty (which is expected because it can switch if there is a magazine with bullets).
Here is the code:
if (Input.GetAxis ("Reload") > 0 && reloading == false && pressedReload == false && runningAutomatic == false && mags[currMag] < magazineSize && animator.GetCurrentAnimatorStateInfo (0).IsName (shootAnim.name) == false) {
for (int i = 0; i < mags.Length; i++) {
if (mags [i] > 0) {
Reload (currMag + 1);
animator.SetFloat ("ReloadSpeed", reloadSpeed);
animator.Play (reloadAnim.name);
pressedReload = true;
reloading = true;
}
}
}
reloading = animator.GetCurrentAnimatorStateInfo (0).IsName (reloadAnim.name);
if (reloading)
pressedReload = false;
...
void Reload (int currentMagazine) {
if (currentMagazine == mags.Length)
currentMagazine = 0;
currMag = currentMagazine;
}
Just forgot to
break;
the for loop... Thanks to Serlite :D