WaitForSecond Corountine Sleep Time Varies

Code:

public float shooting_wait_time = 0.2f;
    
public int bullets;

private bool waiting = false;

void Update() {
	if (Input.GetButtonDown("Fire1") && bullets != 0) {
		if (!waiting) {
			// Do shooting stuff

			StartCoroutine(shoot_wait());
		}
	}
}

private IEnumerator shoot_wait() {
	waiting = true;
	yield return new WaitForSecondsRealtime(shooting_wait_time);
	waiting = false;
}

As you can see I have a Coroutine that waits for 0.2 seconds… The problem is that sometimes it waits the right duration, but sometimes it does a short bursts of no sleep time! I’ve been looking it up for a long time but I have found no solutions for me.

I don’t see what I’m doing wrong. Please help. Thank you in advance.

The problem wasn’t in the code, it was because of a poorly tied to together animator.

Try to use default WaitForSeconds()

I always use it and it works fine for me.