GetKeyDown behaving strange

Hi,

I’m trying to do a shotgun-like weapon that shoots 50 bullets every time I push button “C”. Everything works out just fine except that; if I rapidly push the “C”-button very quick, it seems that my “bulletsInMagazine[5]” is not picking up that it should decrease, even though the bullets get instantiated. I’ve tried to move around “bulletsInMagazine[5] --;” in the code to see if it would react better, but no difference. Have no idea what’s going on here. (It’s inside “void Update”, not “FixedUpdate”)

Thanks!

				float rateOfFire = 0.3f;
				float reloadTime = 3;
				int thrust = 10000;

				if (Input.GetKeyDown (KeyCode.C)) {

						if (bulletsInMagazine [5] > 0) {

								Rigidbody[] bullet = new Rigidbody[50];
								for (int i = 0; i < bullet.Length; i++) {
										Rigidbody shotgunClone = Instantiate (shotgunPrefab.rigidbody, muzzle.transform.position, muzzle.transform.rotation) as Rigidbody;
										shotgunClone.AddForce (transform.forward * thrust);//Speed
										shotgunClone.AddForce (transform.right * Random.Range (-5000, 5000));//Spread
										bullet  *= shotgunClone;*
  •   							justShot [5] = true;*
    
  •   							bulletsInMagazine [5] --;*
    
  •   							Invoke ("JustShot5", rateOfFire); //This sets "justShot" to false*
    
  •   					}*
    
  •   			}*
    
  •   			if (bulletsInMagazine [5] <= 0) {*
    
  •   					Invoke ("EmptyMagazine5", reloadTime); //This refills the magazine after x seconds.*
    
  •   			}*
    

I get the same results with this much simplified code. Do I miss something obvious?

using UnityEngine;
using System.Collections;

public class Weapons_P2 : MonoBehaviour {

int counting = 5;

void Update(){

	if(Input.GetKeyDown(KeyCode.O) && counting > 0){
		counting --;
	}
	else if(counting <= 0)
	{
		Invoke ("ResetCounting",3);
	}

	print (counting);
}

void ResetCounting ()
{
	counting = 5;
}

}