- Home /
Question by
tomeromero · Nov 22, 2010 at 09:46 PM ·
editoreditor-scriptingtime
problem with the digits of my timer
Hi... I have this script
var myTimer : float = 5.0; var myScoreStyle:GUIStyle;
function Update () { if(myTimer > 0){ myTimer -= Time.deltaTime; } if(myTimer <= 0){ Debug.Log("GAME OVER"); Application.LoadLevel("GameOver"); } }
function OnGUI(){ GUI.Label( Rect(Screen.width - 225, 0, 500, 100), "Time: " + myTimer,myScoreStyle);
}
On my screen i see the seconds but something like this if the second is 5 then i see "5.3245746" and countdown to 0. I want to see only the 5 second but not the digits. How can i do this? Thank you. I want to
Comment
Best Answer
Answer by Eric5h5 · Nov 22, 2010 at 10:12 PM
Instead of using
"Time: " + myTimer
use
"Time: " + parseInt(myTimer)