The Unit Spawner component allows you to spawn a unit or multiple unit types in one or more spawn positions depending on its configurations in the inspector.
- Units: Drag and drop the unit prefabs (that have the main Unit component). Each time, one random unit will be chosen from this list to be spawned next.
- Player Faction: Check this field if you want to spawn the units for the player’s faction.
- Faction ID: If the above field is left unchecked, then the spawned units will be assigned to the faction whose ID is the value of this field.
- Free Units: Check this field if you want the spawned units to be free (not belong to any faction in the game).
- Update Population: The spawned units will occupy slots in their faction’s population, if this field is enabled.
- Spawn Positions: An array of Transform components placed in the map’s scene that represent the potential spawn positions of each unit. Each time a unit is spawned, a random element of this array is selected to spawn the units at.
- Destination: When assigned, unit that spawn will proceed to move towards the position represented by the Transform component.
- Amount Range: The minimum and maximum amount of instances of the units to spawn. A random value will be chosen at the beginning inside the assigned range.
- Spawn Reload Range: How long does it to spawn two consecutive units? Each time a unit spawns, the spawn reload value is chosen as a random value inside the assigned range.
- Game Manager: Since this component is not directly initialized by the Game Manager component, it has to be manually assigned through this field.