Tutorial: Load a Scene File at Runtime
Run a .superdex_scene file in SuperDex Unreal without importing it: the file becomes the physics
scene, and a level mirrors it. For how this differs from an editor-authored level, see
Runtime Scene Loading.
This tutorial loads a scene and shows its base scene and prefabs simulating. Creating the scene's bots and driving them from tracked hands takes C++ (see Driving the scene's bots). To see that working, start from the example below.
Try the example first
Open /SuperDexExamples/RuntimeSceneLoad/L_RuntimeSceneLoad and click Play, or use VR
Preview for tracked hands. It loads the repository's runtime_scene_load scene and its tasks,
spawns a roboperator for each slot's bot, and drives the scene's controllers from it. Switch bots
with Ctrl+A and Alt+A, and step through the tasks with B and N. The
Runtime Scene Load example describes the
actor behind it and its settings. The rest of this tutorial builds the smallest level that loads
a scene of your own.
1. Get a scene file
Use any .superdex_scene or .superdex_scene_archive, for example one authored in the
SuperDex Studio Scene Editor. An archive is
self-contained, which makes it the easier file to move between machines.
You can also export one from an editor-authored level. In a level's Event Graph (for example on a
key press), call ExportSuperDexBotScene with an ExportName and an OutputDir, then play
the level in the editor and trigger it. It writes <OutputDir>.superdex_scene_archive, pausing
the simulation while it exports.
2. Make a viewer level
Create a new level for viewing the scene. It must not contain SuperDex Physics components or a
MochiSceneSettingsActor: the scene file is the only source of physics actors and settings, and
the load fails if the physics scene already holds actors. Then:
- Add lights and a sky.
- Add an empty actor, and add a
SuperDexBotSceneVisualizationComponentto it. - Save the level, for example as
/Game/L_SceneViewer.
3. Launch with the scene
Pass the scene with -SuperDexSceneFile=, using an absolute path. From the editor executable:
"%UE_ROOT%\Engine\Binaries\Win64\UnrealEditor.exe" "%CD%\SuperDexUnreal.uproject" /Game/L_SceneViewer -game -SuperDexSceneFile="C:\scenes\my_scene.superdex_scene_archive"
Launching the editor itself with -SuperDexSceneFile= also works: each Play session then
loads the file. For a packaged build, add the level to MapsToCook and pass the same argument to
the packaged executable.
4. Check the load
The output log reports the result:
SuperDexBotSceneSubsystem: loaded '<path>' - <N> actors, <M> bots declared with <K> controllers (none initialized yet), <T> task spawn(s)means the scene is live. The visualization builds its meshes, from the file's.glbrender models where it has them; add-NoRenderModelsto draw collision shapes instead.SuperDexBotSceneSubsystem: failed to load '<path>': <reason>means it is not. The session then runs without physics rather than falling back to the level's own.

Next steps
- To drive the scene's bots, add an
ASuperDexRuntimeSceneLoadExampleto your viewer level and set its Scene File and Roboperators, or adapt its code as described in Driving the scene's bots. The example draws the scene itself, so remove the empty actor from step 2, and add the player setup thatL_RuntimeSceneLoaduses (aSuperDexPlayerStartand theBP_SuperDexGameModeoverride) so its roboperators receive tracked hands. - For the scene format, slots, and
roboperatorClass, see SuperDex Scenes. - To package, see Packaging.