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()?