- Home /
How can i make my scene restart once my character has collided with another object?
Anyone know the JavaScript to restart a level or scene at the beginning if the main character falls off a platform? Help is much appreciated! Thank you!
Comment
Best Answer
Answer by FLASHDENMARK · Jan 15, 2011 at 05:35 PM
function OnCollisionEnter (collision : Collision)
{
if(collision.gameObject.tag == "Type the tag of the object you are colliding with")
{
Application.LoadLevel(Type what ever name of the level you want to restart);
}
}
Answer by The_r0nin · Jan 15, 2011 at 02:59 PM
Well, if you want to restart all over, just like the beginning of the game, you can use Application.LoadLevel(). But if you want to save information (like lives left, etc.) after the restart, you'll need to use DontDestroyOnLoad().