Create First NPC
- Create a new database.
- Create a decision and call it Idle.
In the Idle decision the NPC should stop any movement. We can achieve it using the action Movement > Stop. This action resets the path of the NavMeshAgent. The next action is to play the idle animation. In this example i am using an Animator Controller that has a Speed parameter mapped to a blend tree which defines if the npc is moving or not.
We use the Animator > SetFloat action to set the Speed parameter to 0. This will blend the animation to idle. The final Idle decision looks like this:
- Create one more decision and call it Wander. Use the Movement > Wander action to move the NavMeshAgent arround a radius and Animator > SetFloat with Speed parameter 1 to blend the walk animation.
- Create a two new Decision Score Evaluators.
Set the Weight to 2 and Cooldown to 5 in the Wandering Decision Score Evaluator and leave any Idle Decision Score Evaluator settings as default.
The Cooldown will prevent to select the Wandering DSE within the next 5 seconds. Setting the weight to 2 will always prefer the Wandering DSE compared to the Idle DSE (Without any other considerations).
- Create a new Decision Maker and add the Common Wander and Common Idle DSE to it.
- Create an Intelligence Definition. Right Click on a folder in your project Create > Devion Games > Utility AI > Intelligence Definition, select and add the Base Wander Decision Maker to it.
- Build the NavMesh for the scene.
- Drag and drop your NPC model to scene and add your Animator Controller to the Animator component. Also add the NavMeshAgent component.
- Add the AIController component and assign the created Intelligence Definition to it.