Spawner
Last updated
Last updated
This component allows to instantiate needed amount of copies of certain gameobject, in certain spawn point (or points, randomly) with certain time period.
This could be useful for spawning AI enemies or NPCs in some game area.
For faster experience, you can use Spawner prefab in Assets/Heroic Engine/Prefabs/Gameplay
directory, drag onto your scene and just change some parameters in inspector if needed.
This sample spawner will spawn example object presented in the same folder. This object is just a cube with Rigidbody and LifetimeObject component which returns this object back to pool after certain amount of time.
Object Prefab – prefab that will be spawned by this spawner. In case if it's PooledObject, it will be got from PoolSystem.
Spawn Points – points where these objects can be spawned (if more than 1 point assigned, they will spawn randomly on given points)
Launch Mode – in which way this spawner will be activated.
There are 3 options:
None (spawner can be activated only via its Launch method)
At Start (spawner will be activated automatically at start)
On Trigger Enter (spawner can be activated if collider with appropriate layer enters this spawner trigger zone). Layer can be selected in appropriate field like shown below:
Start Spawn Delay – how much time spawner waits before starting spawn process.
Spawn Period – time period between spawn waves.
Spawn Count – how much objects should be spawned.
This method launches spawning process.
This method stops spawning process.
This method destroys all objects spawned by this spawner (if that objects were pooled, they return back to poll).
This method sets spawn period (in seconds).
This method sets spawn object prefab. If this prefab is inherited from PooledObject, it will be pooled via PoolSystem.
This method sets a certain action which will be invoked each time when object will be spawned.
This method sets a certain action which will be invoked in the end of whole spawning process.