I’ve tried numerous times to look this up. I still don’t seem to get how to use it. I want to be able… in whatever part of my script I want… to wait for a specific number of seconds.
But when I try using the “WaitForSeconds” it usually gives me an error.
example of the script
void Death(){ //basically I'll call this when health <0
death.Play(); //my critters death cry
deathParticles.active = true; //burst of particles
WaitForSeconds(2); // here I want to wait to give the sound and particles time to play out before the destroy
Destroy(this.gameObject);
}
I’ve tried "yield return new WaitForSeconds(2); but that makes it so the “void” has to be taken off the “Death” then I get other errors if I try to do that… if I don’t include the “yield return” part it tells me "expression "denotes a ‘type’ where a ‘variable’, ‘value’ or ‘method group’ was expected.
So… how can I make a script wait for a number of seconds? I don’t know what I’m doing wrong…