I'm a bit of a noob when it comes to Unity scripting. I'm looking for a script that, when placed on an object, when the player character touches that object, the level re-loads itself and the player starts at the beginning again. I've looked around, but I can't be sure of what is right and wrong. May I have some help please?
Application.LoadLevel("nameofscene");
If you are using a character controller :
function OnControllerColliderhit (hit : ControllerColliderHit)
{
if(hit.gameObject.tag == "The tag of the object you are colliding with")
{
Application.LoadLevel("NameOfScene");
}
}
If you are using a rigidbody:
function OnCollisionEnter (hit : Collision)
{
if(hit.gameObject.tag == "The tag of the object you are colliding with")
{
Application.LoadLevel("NameOfScene");
}
}