What I’m doing is I’m taking the roll a ball game the is i the demo projects on the unity side taking the black hole script that causes it to respawn back at the start and trying to make it so that when that happens it subtracts a life. I do have another post on this that is getting quite long I thought I would reword it and see if it make it any easyer to understand. This is the code we have so far>
On my box that if it hits causes it to respawn.
function OnTriggerEnter (other : Collider)
{
other.SendMessage("Die", SendMessageOptions.DontRequireReceiver);
}
On the ball.
var spawnPoint : Transform;
//var theShadow : GameObject;
public var life : int = 3;
function Die()
{
life -= 1;
if(life == 0)
{
Application.LoadLevel("End Game");
} else {
StartCoroutine(DeactivateRespawn());
}
}
function DeactivateRespawn ()
{
gameObject.active = false;
yield new WaitForSeconds (0.5);
transform.position = spawnPoint.position;
gameObject.active = true;
}
function OnGUI(){
GUI.Label (Rect (300, 100, 200, 30), "Life: " +life);
}
What this is causing is the ball to disappear and never come back the gui label is also diapering for some reason.