Hi,
I have a javascript attached to my Laser object that fires out of a spaceship which at the moment is working fine, aswell as some target that float around and when are hit with the laser get destroyed. I also have a score displayed in-game that works Ok but for some reason the score doesn’t update when a target is hit.
Here is my script:
var scoreToAdd : int;
var score : int;
var explosion : GameObject;
var Target : GameObject;
function OnCollisionEnter(col: Collision){
if (col.gameObject.name == "Target"){
Destroy(Target);
Instantiate(explosion,col.gameObject.transform.position,transform.rotation);
score=score+(scoreToAdd);
}
}
function OnGUI(){
GUI.Label(Rect(1200,550,1000,300),"Score: "+score);
}
function Start(){
}