MOST Spawn

The ultimate solution for the object generator. You can use it to Spawn Enemies, set game objects' start positions in awake, generate points, create patterns, and a lot more. Also, it comes with a debugging system, so you can set the area or points you want to spawn in. It's easy to set the target area or target point.

Import MOST Spawn system

1- Create an Empty object in your scene

2- Select this object and tap Add Component

3- Select Most_Spawn.cs, and now you are ready to go

  • The debugging system uses Gizomos drawer, so make sure it turns on in the scene view

  • You can change the drawing settings from Most_Spawn itself

  • The game object that contains the spawn system will be the center point of the spawn area (The shaded area is the spawn area)

The spawn area follows the game object attached to

Set up the Spawn Area

Spawn Area and position settings

Spawn shape: the spawn area shape is between the inner and outer line. Control the scale of this shape using the Inner Scale and Outer Scale. Height is for 3d shape if you want to build a 3d spawn area.

Inner and Outer scales for X and Z axis... Height for Y axis.

Ignored positions layers: The system checks if the selected point has collided with another object If the object is selected by the Ignored position layers, the system will ignore this point and find another What can you do with Ignored positions layers?

  • Stop the spawn objects from overlapping When the spawned object's position collides with the next spawn point, the system will ignore this point and find another to prevent spawned objects from spawning in the same position (or so close to each other)

  • Prevent Spawning above other objects like walls, water, moving objects like characters, and all objects you want to ignore their collision area

  • Shaping complex spawn areas You can use empty objects to draw a complex area and use it to prevent spawning in certain areas inside the spawn area.

Snap Position: Instead of floating point, separate the spawn area into grid points Check Enable Snap, and the debugger will draw the new target spawn points

Well... It's so easy to modify your shape with the debugger drawer anyway :) You don't have to read all of this

Spawn cycle and Spawn rate

Spawn Cycle settings

Let's take a look at Cycle properties

Repeat System: spawn cycles controller 1- Loop forever 2- Limited Cycles

Amount System: spawned objects flow system

  • Divided By Cycle Time: means the amount spawned per cycle will be split between the cycle time

  • Single Swarm: means the amount spawned per cycle will be generated at once at the start of the cycle

Spawn Rate Per Cycle: the number of objects that will be spawned for each cycle

Cycle Time: The cycle time in seconds

Rest Time Between Cycles: the cooldown time between cycles (between the end of the current cycle and the start of the new cycle)

Number of Cycles: (Only if the Repeat System is Limited Cycles, -1/infinity if loop forever) the number of spawn cycles for this system, and after finishing the spawn system will be terminated (but it can be reworked again "Check API at the end of this page")

First Cycle Delay: the delay before activating the spawn system and starting the first cycle (useful at the auto spawn enable and create patterns for multiple spawn systems)

Direction of the spawned objects

Spawn object rotation settings

The target rotation has four options

  • No Rotation: the spawn object rotation will not be affected and will be the same as its prefab

  • Look At Inside Spawn Area: the object will get a random rotation between min and max range starting from the center point of the spawn area

  • Look At Outside Spawn Area: the object will get a random rotation between min and max range starting from the opposite of the center point of the spawn area

  • No Target Rotation: the object will get a random rotation between min and max range

Note: each range is from -180 to 180, and "Target Rotation" Is just centering the start 0 point.

this example shows how "Look At Inside Spawn Area" rotation system works, look outside is the same but reversed

Flow Control

If the number of objects in the scene reaches the "Max number in the scene," the spawn system will stop spawning until the number of objects gets lower than the maximum value (object destroyed/removed)

Note: The limit system only counts the active objects (the destroyed/removed objects are not counted)

Event system

For each spawning event, you can set your functions and calls

  • On Cycle Start Event: Called at the start of a new cycle.

  • On Cycle End Event: Called when the current cycle ends.

  • On Spawn Called Event: Called when the system spawns a new object.

Event system for spawning

Examples

There are unlimited variations of spawn usage. Here are a few examples...

in this example: a continuous bull spawns with rotation (look inside with 60/-60 angle range)
in this example the spawn system is just one cycle to set game objects random position at the start of the scene
you can sync multiple spawn systems easily using cycle control for each spawn system to crearte nice patterns, you will find examples in spawn template with explaination

Explosion template showcase: the enemies generator built using Most_Spawn system

API reference

Last updated