- Home /
Question by
Glen81 · May 22, 2017 at 03:19 AM ·
restart gameontrigger
Restart game with 'Trigger', delay of 60seconds and rests values?
Hi i'm new to Unity, Can someone help with the details of a C Script for the following please: Restart game when a 'player' enters a 'Trigger', it restarts the game taking the player back to their starting position and resets the values, but with delay of 60seconds.
Comment
Well first thing that comes to $$anonymous$$d is placing this script on a trigger collider.
using UnityEngine;
using UnityEngine.Scene$$anonymous$$anagement;
public class GameRestartTrigger : $$anonymous$$onoBehaviour
{
void OnTriggerEnter(Collider other)
{
Invoke("RestartGame", 60.0f);
}
void RestartGame()
{
Scene$$anonymous$$anager.LoadSceneAsync(Scene$$anonymous$$anager.GetActiveScene().buildIndex);
}
}
Your answer
Follow this Question
Related Questions
Alternate for OnTriggerExit??? 5 Answers
Resuming Application on Android 2 Answers