Heroic Engine
  • Welcome
  • Getting Started
    • Quickstart
    • Example Games
      • Tic Tac Toe
      • Turn based duel
  • Basics
    • Injection Manager
    • Engine Systems
      • Core Systems
        • Events Manager
        • Input Manager
        • Localization Manager
          • LangText component
        • Music Player
        • Sounds Manager
        • Time Manager
        • Scenes Loader
        • Day Time Controller
        • Weather Controller
      • Gameplay Systems
        • Currencies Manager
        • Player Progression Manager
        • Quest Manager
        • Random Events Manager
        • Hittables Manager
        • Dungeon Generator
      • UI Systems
        • UI Controller
        • Countdown Controller
    • Editor Tools
      • Clear Saves
      • Mobile Build Optimizer
      • Create System
      • Icon from Prefab Generator
    • Engine Utilities
      • PoolSystem
      • DataSaver
      • ComponentExtensions
      • MaterialExtensions
      • SpriteUtils
      • SlowUpdate
      • StringUtils
      • TypeUtility
      • MathHelper
      • VectorUtils
      • TransformUtils
      • MeshUtils
    • Useful Components
      • Floating Item
      • Fly Up Text
      • Label Scaler
      • Ragdoll
      • Rotate To Camera
      • Orbital Camera
      • Rotator
      • Texture Mover
      • Hittable
      • Projectile
      • Projectile2D
      • LifetimeObject
      • Spawner
      • Colorized Particles
      • Draggable2D
      • SaveableTransform
    • Useful Attributes
Powered by GitBook
On this page
  • How to use
  • Parameters in inspector
  • Available methods
  1. Basics
  2. Useful Components

Spawner

PreviousLifetimeObjectNextColorized Particles

Last updated 4 months ago

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.

How to use

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.

Parameters in inspector

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.


Available methods

public void Launch()

This method launches spawning process.


public void Stop()

This method stops spawning process.


public void RemoveSpawnedObjects()

This method destroys all objects spawned by this spawner (if that objects were pooled, they return back to poll).


public void SetSpawnPeriod(float period)

This method sets spawn period (in seconds).


public void SetSpawnObjectPrefab(GameObject prefab)

This method sets spawn object prefab. If this prefab is inherited from PooledObject, it will be pooled via PoolSystem.


public void SetSpawnCallback(Action spawnCallback)

This method sets a certain action which will be invoked each time when object will be spawned.


public void SetSpawnEndCallback(Action spawnEndCallback)

This method sets a certain action which will be invoked in the end of whole spawning process.

This sample spawner will spawn example object presented in the same folder. This object is just a cube with Rigidbody and 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 .

LifetimeObject
PoolSystem
Spawner prefab
Spawner in inspector
Trigger layer selection