In addition to adding objects to the scene in the editor, you can also create and destroy objects and reusables during gameplay.
You can spawn objects using the Spawner node. By default, the object will be spawned at the position of the spawner node. If you have named reusables in your scene, then you can select one as the Object To Spawn.
For example, here a cube reusable is being spawned into the world.
Spawner can also be used to shoot spawned object towards another object. The Target can be set by linking from Object to Shoot Towards. Force applied is set in the Shoot Force number input. Note that this works only with Dynamic objects.
There are also many other paramters, see Spawner Node for more information.
Once object is spawned, the object is output from the On Object Created
. This is useful if you want to affect the object once it is spawned.
To destroy objects you can use the Destroyer node. When executed, the Destroyer node will destroy the object set in the Target input.
In this example, the cube gets destroyed after 1 second.
Destroyer will also output the destroyed object from the On Object Destroyed
. This is useful if you want to remove objects from a List, for example.