Reload level on collision

I have spent the last 4 hours trying to figure this out with no luck: I’m trying to get the Player (who is a box) to respawn at a set point immediately after coming in contact with the enemy (who is another box). What do i do?

Wow, 4 hours, that’s really a lot of time.

But, to help your problem. What is spawn? It’s basically a movement to certain position (teleport effect), or an actual new player creation. You move your player back to your position using its transform.position = … or use Instantiate for an actual new creation.

Save the position on your start function :

[RequireComponent(typeof(Collider))]
public class Player : MonoBehaviour
{
     private Vector3 original_pos;

     void Start()
     {
           original_pos = transform.position;
     }

     public void reset_position()
     {
           transform.position = original_pos;
     }

     void OnCollisionEnter(Collision coll)
     {
           if (coll.gameObject.tag == "enemy")
           {
                 reset_position();
           }
     }
}

I fixed it.
Here’s the code:

using UnityEngine;
using System.Collections;

public class respawn : MonoBehaviour
{
private object cube;

void OnCollisionEnter(Collision col)
{
    if (col.gameObject.name == "Player")
    {
        Application.LoadLevel(Application.loadedLevel);
    }

}

}
}

}