-
Notifications
You must be signed in to change notification settings - Fork 2
Loading Scenes and Navigating the World
In Stray Photons scenes are large collections of entities that make up a world or map. A single scene represents a chunk of the world that can pop in and out atomically as it is loaded and unloaded. Scenes can define connection points to request another scene be attached, or scenes can be manually added by the user.
A small list of scenes is available to select from the Esc Key Menu. Scenes are defined in assets/scenes/*.json
, where there are many more test scenes and examples available.
You can load any scene from the console using the following command:
loadscene <scene_name>
Examples:
loadscene sponza
loadscene life
loadscene test1
loadscene menu
The default scene menu
, defines a scene connection to station-center
(which in this example is active based on a player proximity trigger and the door open state).
This continues in a chain of scene connections that allows for a full game world to be created without any loading screens.
The default space station demo layout is defined using the following scenes:
game_state (referenced by all) menu - station-center
|
... - blackhole5 - blackhole6 - blackhole7 - blackhole8 - blackhole1 - blackhole2 - blackhole3 - blackhole4 - blackhole5 - ...
You can "fast-travel" to a point in the station by running the loadscene blackhole2
command for example.
Multiple scenes can also be loaded at once with overlapping entity definitions. This allows entities to be overwritten and have state shared between scenes.
And example of this can be seen in the test1
+ test1-override
demo scenes:
loadscene test1
# Add/Remove test1-override scene without unloading other active scenes
addscene test1-override
removescene test1-override
When scenes are loaded, they are placed at a matching scene connection in one of the already loaded scenes, or at the world origin if no connection points are found. Scenes loaded via the console will stay loaded until removed via console, while scenes requested via connection point will be unloaded once there are no more active connections.