"if(Time.time = lastFire + interval;
}
// This is the Invoke test
void InvokeTest()
{
if(canFire)
{
canFire = false;
shotsFired ++;
Invoke ("invoke", interval);
}
}
void invoke()
{
canFire = true;
}
// This is the Coroutine test
void CoroutineTest()
{
if(canFire)
{
canFire = false;
shotsFired ++;
StartCoroutine(Wait(interval));
}
}
IEnumerator Wait(float waitTime)
{
yield return new WaitForSeconds(waitTime);
canFire = true;
}
}
Results:
The FixedUpdate method appears to be the only one that works independent of the framerate. However, that creates another issue, which is that FixedUpdate tends to completely miss Input sometimes.
Is there a solution for that problem?
I do want it to fire exactly when the player presses the fire button.
Thanks again, I really appreciate all of your responses.
Trending Articles
More Pages to Explore .....