I am trying to make it so that when you are near an object, score goes up, but the object that you are near gets destroyed after a certain amount of time. Right now, I’m using the following code, but the object is never destroyed, even as time passes 0:
var Mood : Transform;
var Thought : Transform;
var score : Score;
var time = 1000;
var distanceLimit : float = 5.0;
function Update() {
if (Vector3.Distance(Mood.position, Thought.position) < distanceLimit) {
score.AddToScore () ;
--time;
}
else{
}
if (time = 0) {
Destroy (gameObject) ;
}
Did I do something wrong?
Also, any suggestions are appreciated.
Thanks