Flow graphs can become really powerful when being used as part of a prefab. Doing so is not really difficult since flow graphs are stored as a property of an entity. Embedding a flow graph inside a prefab, for example, is very simple. All you have to do is create a new prefab using an entity that contains a flow graph. The flow graph will automatically be saved within the prefab and will be available whenever the prefab is placed in a level.
Embedded flow graphs can be useful when the created prefabs are supposed to have a certain level of interactivity. Things such as the interior of a room—containing a TV, light switches, or other interactive objects—are quite easy to set up.
As an example, let us build a simple light switch that could be used inside a prefab. For this, we want to set up a Light entity that can be switched on/off using a Switch entity.
The following are the steps to build a light switch:
Create a simple setup containing a Switch entity and a Light...