Flexible Gameplay Tutorial
Scene Graph provides multiple ways to create flexible and dynamic gameplay through the many different interactions between entities and components. This template showcase a few of the ways you can manipulate entities at runtime through spawning and removing entities, and how you can use component events and querying to create communication between entities and build reusable gameplay elements.
Spawning and Removing Prefabs
For example, check out the interactive pad in the second hall. When the player steps on the pad, a prefab lantern is added to the scene and removed when the player steps off the pad.
Open up SpawnPrefabDevice.verse to check out how this code works. This is a creative device that uses a Volume device to know when a player enters it. It then spawns a prefab and removes it when the player steps off the trigger. At the top of the SpawnPrefabDevice class definition, an editable TriggerVolume references the trigger volume in the level.
| | |
| --- | --- |
| | SpawnPrefabDevice := class(creative_device): |
| | |
| | |
| | @editable |
| | TriggerVolume:volume_device = volume_device{} |
SpawnPrefabDevice := class(creative_device): @editable TriggerVolume:volume_device = volume_device{}
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.