Can somebody help me make a scipt, in JavaScript, that allows when a game object collides with another game object, the score adds by 2?
Thanks
Can somebody help me make a scipt, in JavaScript, that allows when a game object collides with another game object, the score adds by 2?
Thanks
Here is an example:
var score = 0;
function OnCollisionEnter (col : Collision){
score+=2;
}
Or if you wanted the score to be a separate script, You would make 2 scripts
Collider Script:
function OnCollisionEnter (col : Collision){
Score.score+=2;
}
Score Script (You would have to name it “Score”):
static var Score = 0;
(Tip, if you wanted to check what the name of the collider is, You would add in):
function OnCollisionEnter (col : Collision){
if(col.gameObject.name == "CollidersName"){
Score.score+=2;
}
}
Hope this helped!
Great this works, but how can I display the score in a 3D text with a font that I have?