To create a new NPC Unit Regulator Data, right-click with the mouse in the project tab and click on: Create -> RTS Engine -> NPC Unit Regulator Data. An asset file will be then created, select it and define the new unit regulator fields.
- Min Amount Range: Minimum amount that must be created from the unit type.
- Max Amount Range: The maximum allowed amount that can be created from the unit type.
- Max Pending Amount: The maximum allowed amount of this unit-type-creation tasks that the faction can have at the same time.
- Create On Demand: Allow NPC components (other than the NPC Unit Creator) to request the creation of this unit type.
- Start Creating After (in seconds): The creation of this unit type will start after the delay provided in this field.
- Spawn Reload Range (in seconds): The timer length that will be used by the NPC Unit Creator to decide whether to create this unit type or not.
- Ratio Range (between 0.0 and 1.0): The ratio of the amount of this unit type to the amount of the population slots which determines the target amount to create from the unit type. If the target amount determined by this ratio is below the minimum amount (above the maximum amount), the NPC Unit Creator will set the target amount to the minimum amount (to the maximum amount).
- Auto Create: Enable/disable the creation of this unit type by the NPC Unit Creator.
Now that we have a NPC Unit Regulator Data asset file in the project tab, let’s use it for a unit type. Select a unit prefab and open its Unit component and open the Regulator Data property of the unit in the inspector and you should now see this view:
Here you can assign a NPC Unit Regulator Data to be used for all NPC types and faction types . Or you can use different regulator data for one or multiple NPC types, one or multiple of faction types or a combination of those two. For example, the Villager unit in the demo game uses two different regulator data files, one for each NPC type in the demo game (“easy” and “hard” NPC types). Notice here that the the Ignore Faction Type is enabled for both of the entries which means that the regulator data will be used regardless of the faction type. Since the Ignore NPC Type field is disabled then the NPC type will be a deciding factor here to pick the right regulator data. The regulator data can be re-used for multiple combinations or different unit types.