Respawn Script (Maxfall)

Hey!
I am currently working on a game, where you are controlling a ball on some grounds n stuff.
When you fall down, you have to respawn. And I tried following script but it doesn’t work:

#pragma strict

var maxFall = -10;

function Update ()
{
if (GetComponent.().position.y <= maxFall)
{
Debug.Log(“Test”);
}

}

Any ideas?

Thanks in advance.

This is a fairly unhelpful statement. What does it do? Does it not trigger? Did you actually attach it to the gameobject that is falling? Did you put a Start() function in there that tells you that it was even instantiated? Did you try setting a breakpoint at the start of Update()? Is your function even running anywhere? These are things you should be able to instantly ascertain in any and every case of scripting and there are plenty of tutorials to guide you there.

I don’t know Java but I think you should have transform.position.y instead of just position.y

This script worked 4 me :slight_smile:

#pragma strict

var maxFallDistance = -10;

function Update ()
{
if (transform.position.y <= maxFallDistance)

Application.LoadLevel (“Level01”);
}