I checked all the variables and everything seems to be set up correctly. I dont want the player to be able to shoot as fast as they can click. hopefully you guys can understand what im trying to do. with the code above the player can still shoot as fast as they want.
Given that the Invoke description doesn’t mention yield working explicitly (whereas StartCoroutine does), and that the code above doesn’t seem to be waiting for the yield I suspect Invoking a method doesn’t let that method then yield.
I’d rather introduced a timer which is increased by Time.deltaTime any frame. Then another variable to hold the shooting frequency. And then it’s as simple as this:
var shootTimer : float;
var shootFrequency : float;
function Update() {
shootTimer += Time.deltaTime;
if((shootTimer >= shootFrequency) (Input.GetButtonDown("Fire1") right == true)) {
Instantiate(bullet,spawner1.transform.position, spawner1.transform.rotation);
shootTimer = 0;
}
if((shootTimer >= shootFrequency) (Input.GetButtonDown("Fire1") right == false)) {
Instantiate(bullet,spawner2.transform.position, spawner2.transform.rotation);
shootTimer = 0;
}
}
edit: Just noticed I might have misunderstood the initial question. Seems like you want to have a delay. In that case a coroutine might help as the others stated.