I have a gun script but I can shoot as fast as I want and Make the animation and sounds skip. So I fire as fast as i can click the mouse. I tried putting this into my code yield new WaitForSeconds(5); but it says “Update() can not be a coroutine”. here the code. (Its a JS) (ps. I’m so sorry, still can not code to look right) Any example/help would be nice. Thanks
var bullet: Rigidbody;
var speed = 50;
var AMMO = 5;
var c : AudioSource;
function Update(){
if(Input.GetButtonDown("Fire2")){
if(AMMO > 0){
animation.Play("shoot");
audio.Play();
var clonedBullet : Rigidbody = Instantiate(bullet,transform.position,transform.rotation);
clonedBullet.velocity = transform.TransformDirection(Vector3(0,0,speed));
AMMO--;
yield new WaitForSeconds(5);
}else{
c.audio.Play();
animation.Play("reload");
AMMO = 5;
yield new WaitForSeconds(5);
}
}
}