2023.1.1294.2 GameObject Spawner
Overview
This component can be used to spawn new GameObjects into the scene. Optionally a blocking area can be set, using a Unity Collider, which blocks spawns if an object is still present within this area.
Where to find
The GameObject Spawner can be found under Mechanics > Spawning> Add GameObject Spawner.
This will add the GameObject Spawner component to the currently selected object or create a new empty GameObject with the component attached if no objects are selected.
Feature Layout
The image below shows the complete feature layout of the GameObject Spawner
| GameObject Spawner |
Recipes | A list of the Recipes to spawn during play mode |
A Recipes element |
|
Name | Name of the recipe. Spawned objects will also receive this name including their spawn number |
Object to Spawn | Reference to the GameObject to Spawn |
Recipe Chance | The chance that this recipe is done (all the changes are added together and then you change is based on (your amount / total amount)). |
Local Spawn Position | The local position within the GameObjectSpawner object to spawn the object. |
Local Spawn Rotation | The local rotation within the GameObjectSpawner object to spawn the object. |
|
|
Random Spawning Seed | The seed of the random generator (this is to make sure that next simulation has the same randomness as the current simulation if values are asked at same order). |
Spawning On | The type of spawning done.
|
Max Amount Of Spawns | The maximum amount of spawns to preform. When set to “-1“, it will spawn an infinite amount of objects. |
Spawn Count | [Read-Only] The amount of spawns done. |
Blocking Area | Reference to the Collider defining the blocking area. When a spawned object is still inside this area, if will prevent the spawner from spawning. This spawn is not buffered. The Object To Spawn has to either have a 'Triggered' Collider or a Rigidbody in order to work properly with this functionallity. The spawner assumes that objects are spawn within this area. When this is not the case, it could be that the spawner only spawns 1 object and assumes spawning is blocked. |
Spawning Is Blocked | [Read-Only] If the Spawning is blocked at the moment. |
How to use
Workflow for a setting up a simple spawner, who spawns an object every second.
Add a GameObject Spawner as component to a GameObject.
Add an element to the Recipes list in the GameObject Spawner’s Inspector.
Create the GameObject wanted to spawn.
Select it in the ObjectToSpawn field.
Set the Recipe Chance to 1.
Go into play mode.
Prespective Documentation