Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

Level counter gets stuck on the first phrase.

$
0
0
As you can tell by the title, I am making a level counter for a game. However, It always gets stuck on the first phrase which is "Tutorial". After that it is supposed to advance to "1" and then up from there. My code looks like this. On door to next level: static var statLevel : int; function OnTriggerEnter (){ if (statLevel == null) { statLevel = 1; } statLevel ++; if (statLevel == 1) { Application.LoadLevel ("Challenge"); MainScript.level = "Tutorial"; } if (statLevel == 2) { Application.LoadLevel ("MageChallenge1"); MainScript.level = "1"; } if (statLevel == 3){ Application.LoadLevel ("MageChallenge2"); MainScript.level = "2"; } if (statLevel == 4){ Application.LoadLevel ("MageChallenge3"); MainScript.level = "3"; } if (statLevel == 5){ Application.LoadLevel ("MageChallenge4"); MainScript.level = "4"; } if (statLevel == 6){ Application.LoadLevel ("MageChallenge5"); MainScript.level = "5"; } if (statLevel == 7){ Application.LoadLevel ("MageChallenge6"); MainScript.level = "6"; } if (statLevel == 8){ Application.LoadLevel ("MageChallenge7"); MainScript.level = "7"; } if (statLevel == 9){ Application.LoadLevel ("FinalTest"); } } And in my main script: static var level : String; public var deathMechanic : GameObject; static var die = true; static var isDying = false; static function deathActivate (){ if (die == true) { if (deathLevel == "Challenge") { NextLevel.statLevel = 0; level = "Tutorial"; } if (deathLevel == "MageChallengeChallenge1") { NextLevel.statLevel = 1; level = "1"; } if (deathLevel == "MageChallengeChallenge2") { NextLevel.statLevel = 2; level = "2"; } if (deathLevel == "MageChallengeChallenge3") { NextLevel.statLevel = 3; level = "3"; } if (deathLevel == "MageChallengeChallenge4") { NextLevel.statLevel = 4; level = "4"; } if (deathLevel == "MageChallengeChallenge5") { NextLevel.statLevel = 5; level = "5"; } if (deathLevel == "MageChallengeChallenge6") { NextLevel.statLevel = 6; level = "6"; } if (deathLevel == "MageChallengeChallenge7") { NextLevel.statLevel = 7; level = "7"; } die = false; Instantiate(activeDeathMechanic, player.position, Quaternion.identity); yield WaitForSeconds (5); Application.LoadLevel (deathLevel); } } function Start () { if (level == null) { level = "Tutorial"; } die = true; if (NextLevel.statLevel == 1) { level = "Tutorial"; } if (NextLevel.statLevel == 2) { level = "1"; } if (NextLevel.statLevel == 3) { level = "2"; } if (NextLevel.statLevel == 4) { level = "3"; } if (NextLevel.statLevel == 5) { level = "4"; } if (NextLevel.statLevel == 6) { level = "5"; } if (NextLevel.statLevel == 7) { level = "6"; } if (NextLevel.statLevel == 8) { level = "7"; } if (NextLevel.statLevel == 9) { level = "Final"; } } Can anyone give me a logical reason as to why this doesn't work and a way to fix it? Your help will be greatly appreciated.

Viewing all articles
Browse latest Browse all 1875

Trending Articles