Spawn Factory Documentation
Getting Started
Adding an Enemy Spawner
➔ Use the provided prefab or create an empty GameObject on your scene and add the EnemySpawner script to it.
➔ Set the ground layer(s) in Spawner Settings. This is required to add nodes to the spawn area and for the enemies to spawn
on.
➔ In the Player Detection tab, use Spawn on Load or set the player layer(s). This is required to detect when the player is within range to begin spawning.
How to keep the spawner working correctly if your enemy doesn’t disable or destroy right away (not needed with Timer spawn type)
➔ Attach the SpawnerCommunicator script to your enemy. This is necessary if your enemy doesn’t disable or destroy right away when dying (and only then)
➔ You will need to call the EnemyKilled() function from your ai script when the enemy is killed.
Example usage:
public void CheckDied() {
if (health <= 0) {
isDead = true;
GetComponent<SpawnerCommunicator>().EnemyKilled();
}
}
Adding Pooling
➔ Use the provided prefab or create an empty GameObject on your scene and the PoolingManager script to it.
➔ In order for an enemy spawner to use pooling you must set the Spawning Method in Spawner Settings to pooling on the
spawner. The spawner will automatically add all enemies to the pool.
➔ Be sure your enemies disable when killed instead of being destroyed.
How to Pool Objects NOT in a Spawner
➔ If you want the pool to persist between scenes add the object onto the PoolingManager. If you otherwise only want to pool
an object in a single scene, create an empty GameObject and add the PoolObjectsInScene script to it (or use the prefab).
➔ Each pool must have a unique tag or you will receive mixed objects.
➔ You will need to call the function GetPooledObject when it’s being spawned and add the PooledObject script to your
object (this requires you disable your object when you want to return it to the pool). Alternatively you may call ReturnObjToPool in your script to return it when you’re ready.
Using Pooled Object
➔ Add the PooledObject script to your object in the pool.
➔ Make sure the pool tag on PooledObject matches the unique tag in PoolManager or PoolObjectsInScene to reference the
correct pool.
➔ Objects in enemy spawners do not need this component.
Note: The pooling manager uses DontDestroyOnLoad.
Adding an Enemy Spawner
➔ Use the provided prefab or create an empty GameObject on your scene and add the EnemySpawner script to it.
➔ Set the ground layer(s) in Spawner Settings. This is required to add nodes to the spawn area and for the enemies to spawn
on.
➔ In the Player Detection tab, use Spawn on Load or set the player layer(s). This is required to detect when the player is within range to begin spawning.
How to keep the spawner working correctly if your enemy doesn’t disable or destroy right away (not needed with Timer spawn type)
➔ Attach the SpawnerCommunicator script to your enemy. This is necessary if your enemy doesn’t disable or destroy right away when dying (and only then)
➔ You will need to call the EnemyKilled() function from your ai script when the enemy is killed.
Example usage:
public void CheckDied() {
if (health <= 0) {
isDead = true;
GetComponent<SpawnerCommunicator>().EnemyKilled();
}
}
Adding Pooling
➔ Use the provided prefab or create an empty GameObject on your scene and the PoolingManager script to it.
➔ In order for an enemy spawner to use pooling you must set the Spawning Method in Spawner Settings to pooling on the
spawner. The spawner will automatically add all enemies to the pool.
➔ Be sure your enemies disable when killed instead of being destroyed.
How to Pool Objects NOT in a Spawner
➔ If you want the pool to persist between scenes add the object onto the PoolingManager. If you otherwise only want to pool
an object in a single scene, create an empty GameObject and add the PoolObjectsInScene script to it (or use the prefab).
➔ Each pool must have a unique tag or you will receive mixed objects.
➔ You will need to call the function GetPooledObject when it’s being spawned and add the PooledObject script to your
object (this requires you disable your object when you want to return it to the pool). Alternatively you may call ReturnObjToPool in your script to return it when you’re ready.
Using Pooled Object
➔ Add the PooledObject script to your object in the pool.
➔ Make sure the pool tag on PooledObject matches the unique tag in PoolManager or PoolObjectsInScene to reference the
correct pool.
➔ Objects in enemy spawners do not need this component.
Note: The pooling manager uses DontDestroyOnLoad.
Enemies Tab
|
Spawn Next Wave Method
Timer: the next wave will spawn based on a timer (and nothing else)
After Wave Killed: the next wave will spawn when all of the current wave is dead
Continuous Kills: Enemies will spawn to a certain point, then after enough are killed more will spawn up to that point.
- Same Timer Each Wave: If this is marked true, every wave will spawn after the same amount of time (set by spawn timer).
- Spawn Timer: How long (in seconds) each wave will wait before spawning the next wave (only usable if Same Timer Each Wave selected).
After Wave Killed: the next wave will spawn when all of the current wave is dead
- Delay Between Waves: How long (in seconds) each wave will wait after all enemies are dead before spawning the next wave.
Continuous Kills: Enemies will spawn to a certain point, then after enough are killed more will spawn up to that point.
- Max Enemies Out: The maximum amount of enemies that may be out at one time.
- Kills Before Spawn More: How many enemies must die before more are spawned.
- Delay Between Waves: How long (in seconds) the spawning will pause between each wave (if this is 0, then waves aren’t noticeable other than spawn order).
Player Detection Tab
|
Spawner Settings Tab
|
- Height From Ground: the height from the ground each new node will be added.
- NavMesh Spawning: if this is marked true enemies will only spawn on the NavMesh (may be combined with obstacle avoidance).
- Avoidance Precision: how many passes will be done to avoid obstacles (higher precision may use more performance) and if it can’t avoid obstacles it won’t spawn the enemy.
- Layers To Avoid: the layers with obstacles to avoid when spawning.
Editor Settings Tab
- Inspector Background Color: the background color of the spawner in inspector
- Inspector Foreground Color: the foreground color of the spawner in inspector (affects no text other than labels).
- Always Show Bounds: if marked true the boundaries of the spawner will show in scene view even when the spawner isn’t selected, otherwise it only shows when spawner is selected.
- Show Area: if marked true the spawner outline will show in scene view.
- Show Handles: if marked true the handles to move nodes will show in scene view.
- Show Nodes: if marked true the sphere caps will show over nodes in scene view.
- Show Start Rotation Arrow: if marked true the arrow indicating start rotation will appear in scene view.
- Show Spawner Label: if marked true the spawner’s name will appear in the middle of the spawner.
- Use Object Name: the spawner’s name will be used as the label in scene view.
- Spawner Name: set your own custom spawner name to show as the label in scene view.
- Show Search Radius: if marked true show wire sphere in scene view indicating player search radius.
- Show Radius Only On Selected: if marked true show player search radius only when the spawner object is selected.
Integration Tab (Only shown if you have an integrated asset with settings)
Vegetation Studio Pro
List of Integrated Assets Note: integrated assets will automatically be enabled or disabled in code when they are added to or removed from the project. |
Pooling Manager Settings Details
- Categories: Only for better organization of your pooled objects. Affects nothing else. Each category will have its own tab in Pooling with a list of pooled objects.
- Pooled Objects: the objects that will be pooled in the pooling manager.
- Pool Tag: the unique tag used to determine which object to retrieve/return to pool.
- Pooled Object: the object prefab to be pooled.
- Amount To Pool: the initial amount of the object added to the pool.
- Can Expand Pool: whether the pool is allowed to grow larger if all objects are currently in use.
Custom Pooling in Scripts
Important Property
public static PoolingManager instance - this holds the unique instance to your PoolingManager. There will only ever be 1 and it may be referenced from any script using PoolingManager.instance to call functions in the PoolingManager.
Functions
Important Property
public static PoolingManager instance - this holds the unique instance to your PoolingManager. There will only ever be 1 and it may be referenced from any script using PoolingManager.instance to call functions in the PoolingManager.
Functions
- Get an object from pool: GetPooledObject(poolTag: string) | Returns a GameObject
- Return an object to pool: ReturnObjectToPool(poolTag: string, obj: GameObject) or ReturnObjectToPool(poolTag: string, obj: GameObject, timer: float)
- Determine if tag is in pool: CheckIfTagInPool(poolTag: string) | Returns a bool
Pooled Object Settings Details
- Pool Tag: the unique tag used to reference the pool you want to return the object to when disabled.
- Destroy After Duration: if marked true the object will automatically disable and return to the pool after set Duration.
- Duration: the duration to wait before automatically returning the object to pool (only works if “destroy after duration” is true).