NPC Upgrade Manager
In this guide, we will go through enabling the NPC faction to launch upgrade tasks through the Upgrade Launcher component that can be attached to units and buildings.
1. Setup Archer Unit Upgrade
Find the tutorial_archer_level2 unit prefab. This unit is the target upgrade of the tutorial_archer_level1 which we set up in a previous guide.
Add the NPC Unit Regulator Data Input component to its parent object and assign the tutorial_npc_archer_regulator to it by matching it with the tutorial_npc_type. Here we are using the same regulator data for both tutorial_archer_level1 and tutorial_archer_level2 because we want to keep the same configurations for the upgrade type of the archer unit.
2. NPC Upgrade Manager
Find the NPC Upgrade Manager component attached to the NPC.Upgrade child object of the tutorial_npc_manager. This component is responsible for launching upgrade tasks for the NPC faction.
- Auto Upgrade: Allow component to launch upgrade tasks when they are available?
- Upgrade On Demand: Allow other NPC components to launch upgrade tasks?
- Upgrade Reload Range: How often does the NPC faction attempt to launch upgrade tasks?
- Acceptange Range: Between 0.0 and 1.0, randomizes upgrade decisions where the higher the value, the higher chance to launch an upgrade.
3. Testing
Play the map scene and allow the game to run for some time then take a look at the NPC Upgrade Manager logs in the tutorial_npc_manager instance in the scene and you can see what current entities have an Upgrade Launcher component and how the NPC factions is trying to launch the archer ugprade task until it succeeds.
Download Files
You can download the results of this tutorial here.