MOST Spawn

The ultimate solution for objects 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.

Check MOST Spawn video to know how to use it in your game (better than reading)

_____ * How to import and use the 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

Note:

  • The debugging system uses Gizoms drawer so make sure it turns on on 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)

_____* How to set up the spawn area? * _____

Spawn shape: the spawn area shape from the inner and outer. 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.

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

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

  • Stop spawn objects overlapping when the spawned object's position collapses with the next spawn point the system will ignore this point and find another to prevent two spawn objects and 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 its 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 to gird points check Enable Snap and the debugger will draw the new target spawn points it's so easy to modify your shape with the debugger drawer anyway :)

_____ * How to set up spawn rate and 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 starting 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 finish the spawn system will be terminated (but it can rework 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)

_____ * Spawn Object Rotation * _____

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 target area

_____ * Limit the active spawned objects in the scene * _____ 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) see examples on MOST Spawn video

Event system: There are event system callers 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.

Note: when the rest time between cycles = zero... "On Cycle End Event" will be called immediately after "On Cycle Start Event".

Another Note: "On Spawn Called Event" will be called once in a single swarm system (multiple objects spawn at the same time).

Another one too 😄: Event system doesn't work with manual spawn calls or manual cycles setter and you have to call it manually as well (logically it has to be this way to make it optional), check the API at the end of this page.

__________ * Examples * __________

there are unlimited variations of spawn usage, here are a few examples and there will be more in the future

__________ * API * __________

Note:

  • all public properties can be updated in runtime and the changes will be set immediately.

  • This is the only API on MOST documentations shows the core cs properties.

// All attributes are set and get so you can modify or call
// Next to each line shows the return and set data Type 

// Functions
// main behavior enable and disable controller
Most_Spawn.EnableState(bool Enable);

// Create a custom cycle next to the main spawn system (even if the spawn system is disabled)
Most_Spawn.CreateCustomCycle(int Amount, float DelayBetweenEachSpawn);

// generate a spawn point and return it
Most_Spawn.GeneratePoint(); return Vector3

// generate a spawn rotation in Euler angle and return it
Most_Spawn.GenerateEulerAngle(Vector3 position); return Vector3

// generate a spawn rotation in Quaternion and return it
Most_Spawn.GenerateQuaternion(Vector3 position); return Quaternion

// return a list of all spawned active objects in the scene
Most_Spawn.GetAllActiveOjectsInScene(); return List<GameObject>

// return a list of all spawned active objects from the current Cycle in the scene
Most_Spawn.GetCurrentSpawnedObjects(); return List<GameObject>

// return a list of all points generated from the current Cycle
Most_Spawn.GetCurrentSpawnedPoints(); return List<Vector3>

// return a list of all rotations generated from the current Cycle
Most_Spawn.GetCurrentSpawnAngles(); return List<Vector3>

// return the last active spawned object, if the last spawn is destroyed:
// Send a debug message and return the one before it, and if the list is empty
// send warning message and error message after, you have to check if the spawn list
// is not empty before you call this function
Most_Spawn.GetLastSpawnedObject(); return GameObject

//_______________________________________________________________//
// Attributes ... all are set and get
// Watch attributes guild video
//_______________________________________________________________//

// ReadOnly variable... return bool if the spawn system is active or not
Most_Spawn.Enable; return bool 

// Spawned object settings
Most_Spawn.SpawnObjectList; return or set List<GameObject>

Most_Spawn.SelectType; return or set(SelectObjectType.Random or SelectObjectType.Loop)

Most_Spawn.AsChildTo; return or set GameObject

//_______________________________________________________________//
// Spawn Area Settings
Most_Spawn.SpawnShape; return or set (SpawnShapeType.Circle or SpawnShapeType.Cube)

Most_Spawn.InnerScale; return or set float

Most_Spawn.OuterScale; return or set float

Most_Spawn.Hight; return or set float

Most_Spawn.IgnoredPositionsLayers; return or set LayerMask

//_______________________________________________________________//
// Snap Settings
Most_Spawn.EnableSnap; return or set bool

Most_Spawn.GridSize; return or set Vector3

//_______________________________________________________________//
// Core Cycle Settings
Most_Spawn.RepeatSystem; return or set (CyclesType.LoopForever or CyclesType.LimittedCycles)

Most_Spawn.AmountSystem; return or set (SpawnType.SingleSwarm or SpawnType.DividedByCycleTime)

Most_Spawn.SpawnRatePerCycle; return or set float

Most_Spawn.CycleTime; return or set float

Most_Spawn.RestTimeBetweenCycles; return or set float

Most_Spawn.NumberOfCycles; return or set float

Most_Spawn.FirstCycleDelay; return or set float

//_______________________________________________________________//
// Rotation Settings
Most_Spawn.TargetRotation; return or set (RotationSettings.NoRotation 
                           or RotationSettings.LookAtInsideShape 
                           or RotationSettings.LookAtOutSideShape 
                           or RotationSettings.NoTargetPoint_Random)

Most_Spawn.RandomRange_Minimum; return or set float

Most_Spawn.RandomRange_Maximum; return or set float

//_______________________________________________________________//
// Flow Control
Most_Spawn.LimitActiveObjectsInScene; return or set bool

Most_Spawn.MaxNumberInScene; return or set float

Last updated