Document toolboxDocument toolbox

WIP 06 | Introducing new Actor Instances to a Scene using a Spawner

Goal: Learn how to use a Spawner to create new Actors in the simulation

Video Tutorial: https://www.youtube.com/watch?v=mx4lx4T0Dkw

In previous tutorials we only used one or two Actors that we placed in the scene ourselves. However, it is more common to spawn Actors during a simulation. This tutorial will explain how to use the Spawner.

First of all, the scene contains a DESController, one Spline with one Cue and a Spawner Instructor with two different Actors. We created a cube Actor and a sphere Actor, both containing an empty script, only defining the objects as Actors. The Spawner makes use of a Blockable Spawner script, which is a predefined script allowing Actors to spawn during the simulation.

Note: The Actor script is empty, except for its class definition. The Actor script, defines the object as a DES Actor, inheriting all characteristics assigned to that class. A script does not need to contain anything besides defining the name and the class, to participate in the simulation.

The spawning Instructor requires both a Spline and a Cue to function properly. The Spline is required to introduce the Actor and define the motional behavior of spawned Actors. The Cue is required to define a blockable area. The size of the Cue defines the blockable area that the spawning Instructor uses to check whether there is space available to spawn a new Actor. If the area already contains an Actor, the spawning is blocked.

We can setup the spawning, by defining spawning recipes in the Inspector. There currently are two existing recipes. The first recipe defines the spawning of the Cube Actor with a chance of 50%. By defining the Tensor Component and setting the thickness equal to the depth (0.05m), we create a solid Actor that moves over the Spline. The second recipe spawns the Sphere Actor with a chance of 50%. We define the Tensor Component to create a solid Actor that translates over the Spline.

The Spawn Interval Range defines the time between each spawn. A new Actor will be tried to spawn each X to Y seconds. Currently both are set to 1, which means a new Actor will try to spawn every 1 second. The first spawn will always happen instantly as soon as the simulation starts.


Play Mode

When we press play, we will see that an Actor will spawn each second and it is a 50-50% chance which of the two Actors will spawn. Once the entire Spline is filled with Actors, the Cue area of the Spawner is blocked and no more Actors can spawn.

 

Prespective Documentation