Changing the starting state of the world
When you deploy a SpatialOS project, the initial state of the SpatialOS world is defined by a
snapshot. The example projects come with a default snapshot
- snapshots/default.snapshot
- but you can modify it or create new ones.
In the RPG demo project, there’s an Unreal commandlet to generate a snapshot, located
in workers\unreal\Source\RpgDemo\ExportSnapshotCommandlet.cpp
.
The commandlet uses the C++ worker API to add a few NPCs to
the world.
The commandlet creates several Entity
instances: these define the entities that will be spawned
when the game starts. You can add your own by using the SpatialOS components and Unreal blueprints you
defined. When you’re happy with your changes, build your new snapshot:
- Compile your C++ changes.
- On the root of your project run
./generatesnapshot.sh
(this will run the Unreal commandlet and overwritesnapshots/default.snapshot
).
Note: You can change the snapshot save name or location by modifying it in the Commandlet code.
Once your new snapshot is built, you can launch your new world with
spatial local launch --snapshot=<your_snapshot_name>.snapshot
.