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)?
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)?
#2
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
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?
Associate John Kanalakis
EnvyGames
John K.