StartCoroutine Flashcards

1
Q

private void OnTriggerEnter(Collider other)
{
If (other.CompareTag(“Powerup”))
{
Destroy(other.gameObject);
hasPowerup = true;
StartCoroutine(PowerupCountdownRoutine());
powerupIndicator.gameObject.SetActive(true);
}
}

A
IEnumerator PowerupCountdownRoutine()
{
yield return new WaitForSeconds(7);
hasPowerup = false;
powerupIndicator.gameObject.SetActive(false);
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Start()
{
StartCoroutine(SpawnTarget());
}

A
IEnumerator SpawnTarget()
{
while(true)
{
yield return new WaitForSeconds(spawnRate);
int index=Random.Range(0,targets.Count);

Instantiate(targets[index]);

}

}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly