Application.LoadLevel Won't Load the next level.

I’ve been working on a game. At the end of a tutorial mission, a debriefing screen is suppose to load after the player reaches the final waypoint.

Here’s the code:

	// Performs a check for all non-timed triggers
	private void ExecuteTriggerCheck(string pReceived)
	{
		int vCounter = 0;
		
		// Iterate through the non-timed trigger list; execute any triggers that has a trigger identical to the received trigger passed to the procedure
		while((vCounter < vTriggerList.Count)&&(vTriggerList.Count > 0))
		{
			Battlestar.Trigger vTrigger = vTriggerList[vCounter];		
			
			if(vTrigger.Name == pReceived)
			{
				// Execute that trigger and remove it from the list
				// Get the first three letters of the trigger ID
				string pCategory = vTrigger.TriggerID.Substring(0,3);
				
				// Compare the category against category types
				if(pCategory == "aud") 
				{
					// Pass the trigger data to the audio execution procedure
					TriggerAudio(vTrigger);
					vTriggerList.RemoveAt(vCounter);
				}
				else if(pCategory == "obj")
				{
					// Pass the trigger data to the generic object execution procedure
					TriggerObject(vTrigger);
					vTriggerList.RemoveAt(vCounter);
				}
				else if(pCategory == "tgr")
				{
					// Pass the trigger data to the trigger load execution procedure
					TriggerNew(vTrigger);
					vTriggerList.RemoveAt(vCounter);
				}
				else if (pCategory == "ftr")
				{
					// Pass the trigger data to the fighter execution procedure
					TriggerFighter(vTrigger);
					vTriggerList.RemoveAt(vCounter);
				}
				else if(pCategory == "end")
				{
					// Ends the mission; currently, it quits the program.
					// In the future, this will be replaced by a load next level statement
					Battlestar.MissionTracker vMission = ResourceManager.LoadMissionTracker(ResourceManager.MissionID());
					ResourceManager.SaveNextMission(vMission.NextMissionID, ResourceManager.Player());
					
					vKillScene = true;
					
					Destroy(vPlayer);
					
					Debug.Log("Destroyed player...");
						
					if(Application.loadedLevelName == "Briefing")
					{
						Application.LoadLevel("Mission");
					}
					else if (Application.loadedLevelName == "Mission")
					{
						Application.LoadLevel("Debriefing");
						Debug.Log("Attempting to load Debriefing");
					}
					else if (Application.loadedLevelName == "Debriefing")
					{
						Application.LoadLevel("Briefing");
					}
				}
				else
				{
					// The trigger did not match any types; send to log; remove trigger
					Debug.Log("Undefined trigger type encountered; trigger deleted from the list");
					vTimeList.RemoveAt(vCounter);
				}
			}
			else 
			{
				// Ignore that item by incrementing the counter
				vCounter++;
			}
		}
	}

The game hangs when the next scene is suppose to load (Application.LoadLevel(“Debriefing”);). I compiled the code, and the output file indicated that it attempts to load the level multiple times. I assume once per update since this procedure is located in the Update() section.

I know that the scene is loaded into the build file. I made sure it was included since it is the most common cause for a LoadLevel failure. That didin’t resolve the issue.

Why can’t it load the next level? and keeps trying to load the level unsuccessfully every Update()?

Try to Debug.Log on your if statement. You will know if your condition ever goes true

Your debug log shows that it tries to load the level multiple times ? That’s not ok, maybe you have an infinite loop somewhere.

Try loading an empty scene and see if it works.

If it works, then debug the constructors of the scripts you are using in the 2nd scene. Maybe an error occurs when an object is instantiated. (the problem is from the loaded scene)

If it doesn’t work, then you are probably having problems with deinitialization of your scene. (so the problem is from the current scene).

Figured it out. I never deleted the trigger that created a true condition that would start the load of the next scene. Consequently, the load routine would attempt to load multiple versions of the next scene that would overload the computer resources and cause it to hang.

I just needed to add vTriggerList.RemoveAt(vCounter) to remove the trigger and stop the routine from getting stuck in a loop.