Game Development Community

Loading a scene on a new thread

by Dave DAmico · in Torque X 3D · 03/27/2009 (11:24 am) · 1 replies

I have two different scenes that load during game play. The second one gets loaded if the user gets to end of level 1. Level 2 takes a while to load and it blocks the game loop. So I was thinking of loading the second scene on a new thread so the first one can continue playing the transition animation. However, I get errors when I attempt to load the new scene. The exception reads "An unexpected error has occurred" on the loader.Load(_currentLevel) line.

public virtual void StartGame(SceneLoader loader, string level)
        {
            EndGame(loader);

            _gameStarted = true;
            _currentLevel = @"data\levels\" + level + ".txscene";

            loader.Load(_currentLevel);

            if (_gameType != null)
                _gameType.StartGame(_playerCount);

            // make sure the GUICanvas has been initialized
            GUICanvas.Instance.OnPreRender();

            // create a GUI for our game
            _CreateGUI();
        }

Is there a better way to switch scenes without blocking the game loop?

#1
04/10/2009 (3:25 pm)
I'd love to know if you get this working. I haven't found an ideal solution for loading scenes either.