Making the AI go to a location when the player enters a proximity trigger

In this recipe, we will demonstrate how you may be able to give a basic Goto command to an AI (Artificial Intelligence) when the player enters a trigger.

Getting ready

  • Open Sandbox and then open My_Level.cry
  • Complete the How to beam the player to a tag point from a trigger recipe to learn how to place the proximity triggers
  • Then place down a new Grunt

How to do it...

  1. First, place down a proximity trigger and a solid with the same dimensions and properties as the previous recipe.
  2. Then place down an AI tag location within that same trigger area.
  3. Next, create a new Flow Graph from the trigger area called AI_Goto.
  4. Within the Flow Graph, create the following logic:
    • From the perspective viewport of the editor, select the ProximityTrigger and the TagPoint
    • Add Selected Entities to the Proximity Trigger Flow Graph
    • Add Node | AI | AIGoto
  5. Select a Grunt from the perspective viewport.
  6. Back in the Flow Graph, right-click AIGoto | Assign Selected Entity.
  7. Link Enter output from the ProximityTrigger to the Sync input of AIGoto.
  8. Link pos output from the TagPoint to the pos input of AIGoto.
    How to do it...

With that logic now set up, the AI should now attempt to go to that tag point (unless its behavior is interrupted by perceiving the player).

How it works...

With the AIGoto node, this trigger is a nudge to the AI's behavior tree to signal a basic command for the AI to go to a specific location. Unless the AI's behaviour is not currently busy with other tasks, the AI will proceed to the defined location.

There's more...

Here is an extra Flow Graph node you might want to try as well.

AIGotoEx

An extended version of the AIGoto node is the AIGotoEx. This node allows the designer to forcefully command the AI to go to a particular location regardless of the current condition of its state. This is a key node to use if the designer wants to force the AI to retreat for example.

See also

  • The Debugging the Flow Graph recipe
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.133.233