Skip to end of metadata
Go to start of metadata

This article is largely obsolete and is only applicable for CRYENGINE 3.4 or earlier. For CRYENGINE 3.5 and later, see the Basic Navigation tutorial.

Overview

This tutorial describes how to make an AI character walk to a specific point in a level by setting up a simple Flow Graph.

Preparation

  1. Place an AI Grunt Entity (RollupBar -> Objects -> Entity -> AI -> Grunt) in the level.
  2. Place a TagPoint (RollupBar -> Objects -> AI -> TagPoint) in the level.

Setting Up the Flow Graph

  • Select a TagPoint and click the Create button in the Flow Graph section of the Entity properties. Or, right click the TagPoint entity and select Create Flow Graph.

  • Specify the group in which the Flow Graph will be saved, or create a new one. Enter a name for the new group, if you have selected to create a new group.
  • With the TagPoint selected in the Perspective View, right-click the main editing pane of the Flow Graph and click Add Selected Entity on the context menu.
  • Make sure that the new TagPoint node can be seen, either by zooming in with the mouse wheel or by selecting Fit Graph to View from the menu.

Adding an AIGoto Node

  • Add an AIGoto node, which will make an AI Entity go to a point when the Flow Graph is triggered. Right-click the main editing pane of the Flow Graph Editor and select the AIGoto node (in the AI sub-menu).
  • Add a Start node from the Misc sub-menu.

Connecting the Nodes

  • Keep the mouse button held down while dragging the line from the output of the Start node to the Sync port of the AI:AIGoto node.
  • Do the same for the pos out port of the Entity:Tagpoint node to the pos port of the AI:AIGoto node.
  • Now, you need to tell the system which Entity should be used.
  • Keep the Flow Graph window open and select your AI Grunt in the Perspective View, then right-click the AIGoto node and select Assign selected entity.

After you are finished, the flow graph should look like this:

The AI will walk to the TagPoint automatically when the user begins the level.

It is important to remember, that if the AI can see the player, it will cause the AI to break all Flow Graph actions and enter combat mode, or take defensive action if it does not have a weapon assigned to it.

For testing purposes, type in ai_IgnorePlayer 1 in the console to avoid this if it's an issue.

As an alternative, you can press the Play button at the top of the Flow Graph window or the AI/Physics button at the bottom of the Sandbox Editor's main window in order to test the Flow Graph setup.

For debugging purposes, turn on AI_DebugDraw 79 to see information about the AI's actions.

Adding Forbidden Areas

If the AI has trouble navigating obstacles in the level, try adding a ForbiddenArea around the obstacle.

  • On the RollupBar go to Objects -> AI.
  • Double-click the ForbiddenArea object to start drawing the shape in your level.
  • Make sure either the Follow Terrain or Follow Terrain and Snap to Objects button is turned on
  • Click on the terrain to place the first point in the shape. Click as times as you need to in order to surround an object with the ForbiddenArea. Double-click to close the shape.

  • From the AI menu select Generate all navigation.

Note that if your level is very large, this can take a long time, and it is best to first place all of your FobiddenAreas and then only Generate all navigation once.

Now, select AI/Physics to test the AI's navigation around the forbidden area.

 

 

  • No labels