Lives/Death Script

Hi, I’ve got a game which is two balls on a platform, and they’ve got to push the other off, best of 3. But I’m struggling with the ‘dead’ script (when they fall off the side, collide with my floor and lose a life and restart).

The issue is - I’m not using a Character controller on either ball - so CharacterColliderHit doesn’t work. How can I rectify that?

Script -

private var dead = false;

function OnControllerColliderHit(hit : ControllerColliderHit)

{
	if(hit.GameObject.tag == "Death Zone")
	{
		//dead = true;
		Debug.Log ("Dead = True");		
		//Lives.AmountLives -= 1;
		
	}

}

I want it to find an object (rather than a tag), or make it work on just a general hit, not a controllercollider.

Thanks
p.s. I’m really new at this, and I honestly have searched for an answer :frowning:

Use

private var dead = false;

    function OnCollisionEnter(hit : Collision)
    {
        if(hit.gameObject.tag == "Death Zone")
        {
           dead = true;      
           Lives.AmountLives -= 1;
        }
    }

and in update:

if(dead){
    transform.position = Vector3(x,y,z); //Location where you want the ball to respawn
    dead = false;
}