Game Development Community

SceneLoader problem with TorqueX 2.0

by Thomas Wrather · in Torque X 2D · 04/03/2008 (6:00 pm) · 4 replies

Still working on porting a game from TorqueX 1.0.5.1 to 2.0...

Moving from level 1 to level 2 now causes an assertion failure "RenderMaterial.SetupEffect - Failed to load effect!"

The basic code flow for moving from level to level is:

Game.Instance.Engine.GameTimeSchedule.Schedule(5000, Manager.Instance.ScheduledLevelChange);

...

public void ScheduledLevelChange(object sender, ScheduledEventArguments scheduleEventArguments)
{
SceneLoader.UnloadLastScene();
SceneLoader.Load("data\levels\levelData2.txscene");

... code to spawn player from a template and setup camera and view
}

I can step through all this code with no problem. I even hit breakpoints in component ProcessTick calls for a while before the assertion fires.

Is it OK to load/unload in a scheduled callback? Is there a way to find out what "effect" could not be loaded (I don't have the pro version)?

#1
04/03/2008 (11:58 pm)
First off, you can definitely load/unload anytime you want, even in response to a scheduled callback. My guess is that if you try to unload/load any other time (outside of a schedule callback), you'll get the same problem. As far as I can tell, there is a general problem with the Unload() method blasting away everything - including the scenegraph. As I recall, you need recreate the sceneview before loading the new scene into it. I'll see if I can find the code for this.

John K.
#2
04/04/2008 (5:51 am)
Thomas,
Try this. I was having the same problem, but outside of a callback, so that isn't the problem.
John is right, when you call Unload on a txscene it is clearing out everything associated with it. If it happens to be the only txscene loaded it also clears out all the base objects TorqueX needs. They are not auto-recreated when you load the next txscene. Instead of recreating the scenegraph, camera, and everything else in code I just create a blank scene that is loaded first and never unloaded until the game ends. This keeps all the necessary txscene objects around as you load/unload others on top of it.

--Tom
Starlit Sky Games
#3
04/04/2008 (7:31 pm)
Tom, I tried your solution. Either I've been up too long, or my program has other issues. I'm still seeing the assertion.
#4
04/09/2008 (4:15 pm)
John, any luck locating that code?