Hi Guys,
I’m very new to programming. But I have spent hours trying to do one thing and I can’t work it, so I’m asking for help.
What I am trying to do is destroy my Player and then after a few seconds respawn it back in but I am also doing this in a script that isn’t the Player script. I am trying to do this with coroutine and the IEnumrator. I know how to use the coroutines as I have already set something else up.
Here is how the code is setup that I want to do this in.
void OnCollisionEnter2D(Collision2D collision){
ScoreManager.score +=ScoreValue;
StartCoroutine(Respawn());
}
IEnumerator Respawn(){
//Destroy the character
yield return new WaitForSeconds(3);
//respawn
}
}
Any help would be much appreciated