How do I make an object respawn after reaching a certain height?

This is the script I’m using right now on the most updated free version of Unity. I’m following the directions in this video 5. Shadows & Respawn - MAKE A GAME (Unity) - YouTube and I’m referring to the script used at the 13:30 minute mark, although the one shown before that doesn’t work either. It looks bad here, but I have it 100% correct in the editor and it refuses to do anything. Help please?

 #pragma strict

 var maxFallDistance = -10;

 function Update () 
 {
	if (transform.position.y <= maxFallDistance)
	{
		Application.LoadLevel ("Level 1");
	}
 }

1 Answer

1

The only problem I could think of is maybe your level/Scene name is wrong, but if that doesn’t work you can always create a spawn point and a kill zone, which could be used to make checkpoints, instead of reloading the scene again.