Spawn Troubles...

i have this script:

var speed = 3.0;
var rotateSpeed = 3.0;
private var dead = false;

function OnControllerColliderHit(hit : ControllerColliderHit)
    if(hit.gameObject.tag == "fallout")
        dead = true;
function Update ()
        var controller : CharacterController = GetComponent(CharacterController);
        transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
        var forward = transform.TransformDirection(Vector3.forward);
        var curSpeed = speed * Input.GetAxis ("Vertical");
        controller.SimpleMove(forward * curSpeed);

function LateUpdate() { if(dead) { transform.position = Vector3(.55,.36,-5.73);

        dead = false;


@script RequireComponent(CharacterController)

And its supposed to move a ball around them when it falls off an cliff re spawn at a given location, but when i fall off the cliff it just keeps falling.

What is wrong in my script or how else can i achieve this???


First of all, this script will only work on a CharacterController object, it won't work for other "normal" types of rigidbody physics objects. Because you mentioned that this is a "ball" moving around, perhaps you're using a regular rigidbody?

Secondly, it looks as though the script relies on a large catch-all collider, which probably should be positioned under the play area, and extending far enough to ensure that anything which falls off will definitely hit it. Make sure this object is present.

Thirdly, that catch-all collider needs to be tagged as "fallout". Tags are case-sensitive. If you're unsure about how to create a tag and tag a gameobject, see in the manual here.