Quantcast
Channel: Questions in topic: "static variables"
Viewing all articles
Browse latest Browse all 84

Static Variable Doesn't Change ?

$
0
0
Hello Unity Community. I'm very anixous about a code :S There's a code i translate form C# to .js #pragma strict /////////////////////////////////////////////////////////// var startTime : float; var restSeconds : float; var roundedRestSeconds : int; var displaySeconds : float; var displayMinutes : float; var timeLeft : float; static var countDownSeconds : int = 15; var timeText : String; /////////////////////////////////////////////////////////// function Start() { startTime = Time.deltaTime; } /////////////////////////////////////////////////////////// function OnGUI () { timeLeft = Time.time - startTime; restSeconds = countDownSeconds - (timeLeft); roundedRestSeconds = Mathf.CeilToInt(restSeconds); displaySeconds = roundedRestSeconds % 60; displayMinutes = (roundedRestSeconds / 60) %60; timeText = (displayMinutes.ToString() + ":"); /////////////////////////////////////////////////////////// if (displaySeconds > 9) { timeText = timeText + displaySeconds.ToString(); } else { timeText = timeText + "0" + displaySeconds.ToString(); } var textMesh : TextMesh = gameObject.GetComponent(TextMesh); textMesh.text = timeText.ToString(); } everthing is fine with code but I've assigned 2 more codes from outside. First one is ; #pragma strict var gameOver : GameObject; function Start () { yield WaitForSeconds(15); Time.timeScale = 0; gameOver.active = true; } wait 15 seconds than stop whole game time. so it works fine too. but when i try to reset counter time with this code ; #pragma strict var isSaveDucks = false ; var GameOver : GameObject; function OnMouseDown() { if (isSaveDucks) { Application.LoadLevel(2); } if(!isSaveDucks) { CountPoints.Score = 0; Timer.countDownSeconds = 15; Application.LoadLevel(Application.loadedLevel); Time.timeScale = 1; } } It does'nt work :( I must do this so please help me ! I'm Stuck. (P.S. I'm 14 years old sorry for my bad english :/ )

Viewing all articles
Browse latest Browse all 84

Trending Articles