Rather than a destination that is fixed when the scene starts, let's allow the Capsule-destination object to be moved by the player while the scene is running. In every frame, we'll get our NPC arrow to reset the NavMeshAgent's destination to wherever Capsule-destination has been moved to.
NPC to seek or flee from a moving object
Getting ready
This recipe adds to the previous one, so make a copy of that project folder and do your work for this recipe with that copy.
How to do it...
To make an NPC seek or flee from a moving object, follow these steps:
- In...