- Home /
Car Tutorial scoring
So, i'm attempting to make a score for a the car tutorial.. It's for class and i'm having some issues with it. I'm probably doing something wrong with my coding but i'm attempting to take the basic car and keep the script the same if possible and drive it around on terrain and go off jumps or whatever. What i'm trying to do basically is if the car isn't on the ground I want to add a point to the score Gui every second/frame or whatever that it isn't on the ground and I cannot for the life of me figure out how to do it.. My prefab of the car itself is named Car and my GuiText is scoreGui. Any help would be amazing.. I've tried everything I can think of and it just isn't clicking with me..
var score: int = 0; static var drive = false;
function CalculateState() { { for(gameObject.tag == "Car") { if(gameObject.isGrounded){ var drive = true; } else{ score += 1; guiText.text = "" + score; } }
}
}
I've done a slight bit of research and been able to possibly find something more useful to do what i'm trying to do.. but it still isn't working fully
else{
var myScore : GUIText = gameObject.Find("ScoreGui").GetComponent(GUIText);
var score: int = 0;
score ++;
myScore.text = "Score: " + score;
}
I'm attempting to add this to the carScript itself and try to update the score with it attached to the prefab as well.. but i'm not really sure
I'm personally not even sure if that is the right way of going about it.. I just want to do a basic score update whenever the car is in the air
do I need to give the car script as well? Is it just that people don't know what i'm actually talking about? I can do that if its needed..
So I fixed it slightly.. It now shows my Score: 1 but it never changes.. it stays at that static 1 no matter what happens
apparently I can fix my own mistakes.. i ended up making just a regular var for score ins$$anonymous$$d of down under the else statement and that fixed it.. it updates like I want it to.. It starts at 4, but that isn't a huge deal in my opinion
Your answer
Follow this Question
Related Questions
Highscore Save 0 Answers
Scoreboard will not update 1 Answer
Don't destroy script on load 2 Answers
Money System Not Working Please Help!!!! (Code fully commented!) 3 Answers
When should I save data 2 Answers