i was using this code to keep track to time in my game and also to change the scene once the time had reached 0 (well -1 wouldn’t work with 0 not sure why) it was working fine on loads of tests i then clicked build and run to see it it worked on my iPhone and i receive errors with this script file unfortunately i don’t understand what iv done wrong if anyone could please help… heres the error codes i get and my script if its any help
Assets/Timer.js(37,29): BCE0051: Operator ‘-’ cannot be used with a left hand side of type ‘float’ and a right hand side of type ‘Object’.
Assets/Timer.js(41,5): BCE0005: Unknown identifier: ‘restSeconds’.
Assets/Timer.js(47,42): BCE0005: Unknown identifier: ‘restSeconds’.
Assets/Timer.js(56,5): BCE0005: Unknown identifier: ‘text’.
Assets/Timer.js(63,41): BCE0005: Unknown identifier: ‘text’.
private var roundedRestSeconds : int;
private var displaySeconds : int;
private var displayMinutes : int;
var TimeLeft = "Time Remaining:";
var countDownSeconds : int;
var mySkin : GUISkin;
function Awake() {
startTime = Time.time;
}
function OnGUI () {
GUI.skin = mySkin;
var guiTime = Time.time - startTime;
restSeconds = countDownSeconds - (guiTime);
roundedRestSeconds = Mathf.CeilToInt(restSeconds);
displaySeconds = roundedRestSeconds % 60;
displayMinutes = roundedRestSeconds / 60;
text = String.Format ("{0}:{1:0}", displayMinutes, displaySeconds);
if ( displaySeconds == -1)
{
Application.LoadLevel(1);
}
GUI.Label (Rect (120, 40, 110, 30), text);
GUI.Label (Rect (20, 40, 110, 30), TimeLeft);
}