- Home /
This question was
closed Oct 07, 2013 at 01:18 PM by
Fattie for the following reason:
Duplicate Question
Question by
Kebabs · Oct 07, 2013 at 01:17 PM ·
timerdelaytimer-script
A timer function to delay something
Hi
I am trying to add a delay to my respawn. The respawn at the moment simply relocates the player to x position and resets there health. All I want to do is delay the respawn so it doesn't happen instantly and can give the player a slight breather before the action kicks off again.
Any help is greatly appreciated, and heres some code if it helps.
if (playerHealth <=0)
{
killPlayer();
playerLives -=1;
}
void killPlayer()
{
//add delay here before doing the rest of the script
player.transform.position = new Vector3 (-3, -3, -1);
playerHealth +=100;
if (playerLives <=0)
{
Application.LoadLevel (1);
playerLives +=3;
}
}
Comment
use Invoke() Pls search on here for literally 1000s of examples.