Devlus
1
var score = 0;
guiText.text = "Score: "+score;
function OnCollisionEnter(hit : Collider) {
if(hit.gameObject.name == "bug enemy pre(Clone)"){
{
score += 5;
}
}
}
It's pretty straight forward, but basically on collision with the enemy object, I want the score to move up by 5. I'm getting an error that says "Assets/score.js(9,11): BCE0044: expecting :, found '+='." I'm sure this is a super simple error, and I have tried changing some things around, but this seems like the smoothest solution, so a little help would be very much appreciated. oooooo, and anyone who gives an answer (that solves my problem) can call me an idiot! And its JS...
"score ++ 5" isn't valid syntax. "score += 5"
Is this helping ?:
var score = 0;
guiText.text = "Score: "+score;
function OnCollisionEnter(hit : Collision)
{
if(hit.gameObject.name == "bug enemy pre(Clone)")
{
score += 5;
}
}
Not sure if this is fixing it,but you had brackets to many.
Devlus
4
Ok using both of your advice i fixed it to an un-bugged version! thanks... i'm not sure who to mark correct, because you both were right... anyway here is the working code
var score = 0;
guiText.text = "Score: "+score;
function OnCollisionEnter(hit : Collision){
if(hit.gameObject.name == "bug enemy pre(Clone)"){
score += 5;
}
}
whether this code works or not is for another day, anyway thanks all