The NPC Building Regulator Data is responsible for regulating the creation of one or multiple building types for one or multiple NPC types, one or multiple of faction types or a combination of those two.
To create a new NPC Building Regulator Data, right-click with the mouse in the project tab and click on: Create -> RTS Engine -> NPC Building Regulator Data. An asset file will be then created, select it and define the new building regulator fields.
- Min Amount Range: Minimum amount that must be created from the building type.
- Max Amount Range: The maximum allowed amount that can be created from the building type.
- Max Pending Amount: The maximum allowed amount of this building-type-creation tasks that the faction can have at the same time.
- Create On Demand: Allow NPC components (other than the NPC Building Creator) to request the creation of this building type.
- Start Creating After (in seconds): The creation of this building 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 Building Creator to decide whether to create this building type or not.
- Auto Create: Enable/disable the creation of the building type by the NPC Building Creator.
- Regulate Per Building Center: When enabled, the building’s minimum and maximum amount values will only be considered for the buildings that belong to the same building’s center territory (a building center is a building with the Border component). When disabled, then the min and max amount values will be considered for the whole NPC faction’s territory.
- Placement Option: Determines how the building will be placed. There are three options:
- Around Center: Building will be placed around the building center that it belongs to.
- Around Building: Building will be placed around a certain building.
- Around Resource: Building will be placed around a certain resource type.
- Placement Option Info: Depending on the chosen Placement Option, this field will different interpretations. In the case of:
- Around Center: You can keep this field empty.
- Around Building: Input the code of the building that you want this building to be placed around.
- Around Resource: Input the name of the resource type that you want this building to be placed around.
- Build Around Distance: defines the minimum distance between this building type & its build around object.
- Rotate: When enabled, the NPC faction will rotate the building towards its building around object.
Now that we have a NPC Building Regulator Data asset file in the project tab, let’s use it for a building type. Select a building prefab and open its Building component and open the Regulator Data property of the building in the inspector and you should now see this view:
Here you can assign a NPC Building 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 Warehouse building in the demo game uses one regulator data file for all faction and NPC types.
Now that we know how to create regulator data assets for units and buildings, it’s time to go back to the NPC Manager prefab and start modifying the NPC component which regulate how the NPC faction will act during a game.