To specialize how the NPC will respond, we need to write specific conditions and response classes and then populate the DecisionMgr
for the NPC by placing these components in the editor. To prove this, let's develop a test case for an NPC that will perform the following logic:
Patrol on a curve, facing forward.
When the NPC gets close enough to the player, stop and face the player.
When the NPC is far enough away from the player, follow the path and face forward.
To implement this logic, we will need two conditions and one response.
Let's create a condition to check if the NPC is close enough to the player. This will be used by the npcDecisionMgr
to determine when to stop patrolling and face the player.
Create a new script called
condition_closerThanthresh
.In MonoDevelop, edit the signature of the class declaration so that it inherits from
npcCondition
rather thanMonoBehaviour
. Also, add the...