I wrote this script, and when I hold down the mouse to activate the full auto bool, all the bullets come out with no delay between them. How would I make it so that there is a delay between when the bullets are shot, CurrentAmmo is reduced by one, and the ShotSound is played? (Meaning that when these happen all at one, how would I make a delay before it repeats?)
while (isFullAuto == true) {
if (CurrentAmmo <= 0.5)
break;
RaycastHit hit;
if (Physics.Raycast (WeaponCamera.transform.position, WeaponCamera.transform.forward, out hit, range)) {
Debug.Log (hit.transform.name);
health = hit.transform.GetComponent<EnemyHealth> ();
if (health != null) {
health.TakeDamage (damage);
}
if (hit.rigidbody != null) {
hit.rigidbody.AddForce (-hit.normal * hitForce);
}
GameObject impactGO = Instantiate (impactEffect, hit.point, Quaternion.LookRotation (hit.normal));
Destroy (impactGO, 2f);
}
CurrentAmmo--;
shotSound.Play ();
}