- Home /
coin collecting with onscreen score
var score = 0;
function OnTriggerEnter( other : Collider ) {
if (other.tag == "Coin") {
score += 5;
Destroy(other.gameObject);
}
}
i use this code to collect coins, but cannot get it do display onscreen, i'm not a programmer, just a designer, so can advice a simple help? :)
Comment
Answer by Tetrad · Jul 12, 2010 at 03:12 PM
function OnGUI()
{
GUILayout.Label( "Score = " + score );
}
Put that in your script.
i'll try it now, does this script keeps the score for a next level, or i have to search forward? :)
PS it works :) and by the way how can i change the font since it's not a GUI text object
when i collect the coin, i get the score, but i respawn to the beginning :c any idea why?
Your answer
Follow this Question
Related Questions
Currency score increase on pickup 1 Answer
How to make a Score GUI. 0 Answers
Why this Error when trying to add a score using the new GUI ? 0 Answers
Score and gui help 1 Answer