My trees keep on falling at the same time and I am not sure why! I am new to Unity3D javascript.
Here is my script:
#pragma strict
//INTS
var health = 5;
//GAMEOBJECTS
var tree : GameObject;
var log : GameObject;
function Start () {
tree = this.gameObject;
}
function Update () {
if(Input.GetKeyDown(KeyCode.Mouse0) && Player_script.axehave && health >= 1 && Camera_script.tree){
health -= 1;
}
if(health == 0){
tree.GetComponent.<Animation>().Play();
Destroy();
}
}
function Destroy(){
yield WaitForSeconds(2);
Destroy(tree.gameObject);
}