Game Development Community

Unloading/Loading new missions (levels)

by George Tagmire · in Torque Game Engine Advanced · 12/05/2009 (4:10 pm) · 3 replies

I have been working with TGEA 1.8 for the past fews months now and I am still having trouble with swapping out missions. We have it set up currently through triggers. When the player reaches the end of the level, the trigger is called to load the next mission after playing a cutscene. The cutscene plays, and after it is done or the mouse is clicked the next level begins to load. Occasionally the next level loads just fine and everything is perfect, but more often Torque freezes while loading the mission and does not respond.

This is of course a major problem. We have 7 levels to our game. Id say you could probably make it completely through about 5% of the time, while 95% of the time it crashes upon loading one of the levels. Every level loads perfectly fine if loaded first as the default mission. A level also loads fine if reloaded. Ive tried rehashing the Stronghold level select but it also gives me the same results. Another side note is that while opening mission files through the editor, we sometimes also encounter the crashing.

So onto my question. If I cannot successfully load each level one after another, is there a way to completely almost "end the game" and make TGEA think you are starting fresh, but while changing the default mission to the next level? Ive tried endGame(), disconnect(), destroyServer(), etc. We are in desperate need of help, so any is appreciated! Thank you.

Extra Notes:
-Single Player game
-No real error codes in console
-Tried everything I could think of =)

#1
12/06/2009 (4:26 am)
I've had it crash before on me and from what I found was loading from a mission to a gui then trying to load another mission does not work. You have to disconnect from your previous mission. What you need to do is disconnect from that mission and then load the cut scene. After this you then load the next mission. All this can be done easy if you just write a function or two in one of your cs files.
#2
12/06/2009 (4:27 pm)
But the loading screen is also a gui, correct?

Ive tried not even using the cutscene and instead just jumping right into the next level load. Still crashes. Ive also tried ending the game completely using endGame and disconnect(), which gives me that purple screen. But that still crashes also, once it begins to load.
#3
12/07/2009 (2:06 am)
Yes the loading screen is a gui. But from what I've gathered from a few past learn and go mistakes was that when I didn't disconnect from a mission and tried to load another (or reload the one I was just in) it would crash at the loading screen at times. I had success after disconnecting first then loading another mission. Just try creating a function like below and calling it when you want to load to the next level.
function disconnectandload()
{
   disconnect();
   Canvas.setCursor("DefaultCursor");
   createServer( "SinglePlayer", expandFileName("~/data/missions/newmissionname.mis") );
   %conn = new GameConnection(ServerConnection);
   RootGroup.add(ServerConnection);
   %conn.setConnectArgs($pref::Player::Name);
   %conn.setJoinPassword($Client::Password);
   %conn.connectLocal();
}