Skip to end of metadata
Go to start of metadata


This tutorial will show you how to control basic AI navigation through Flow Graph. Feel free to create a new level while running through this tutorial, or open the attached level for a completed setup.

Environment Setup

To get started, create a new level in Sandbox. In this example the level is called "AI_Test_BasicNav".

First thing you want to do in your level is raise the terrain above ocean level or lower the ocean level. See more on that here: Creating a New Level.

Once you've got some play area, create a large Navigation Mesh area. Set it to "MediumSizedCharacters" which the standard AI characters are.

To check that your Nav Mesh looks ok, navigate to AI -> Debug Agent Type -> MediumSizedCharacters.

If it's a good mesh, it will show up blue. If you see nothing, try sinking the mesh into the terrain further (in case it's floating above the terrain).
You should always try and ensure that the Navigation Area is below the terrain surface to prevent any issues with the nav mesh generating correctly.

Object Placement and Setup

Now that you've got an area where the AI can freely navigate in, lets add some required assets that we'll use for our logic in the next step.

We'll use a couple of TagPoints which can be very useful for obtaining positions. So drop a tag point in the level via RollupBar -> AI -> TagPoint

After that, drop an AI character inside the NavMesh area via RollupBar -> Entity -> AI -> Characters -> Human

Next, create a Flow Graph container via RollupBar -> Entity -> Default -> FlowgraphEntity

Call the group something like "AI_Move", but the name doesn't matter.

Flow Graph Logic Setup

Now that you've got your FG (Flow Graph) container ready to go, we can start putting in the FG nodes needed to perform basic AI navigation.

Like with most FG's, start off with a Game:Start node and link that to the "Sync" port of an AI:GoTo node.

Since CRYENGINE 3.6.3, the AI:Goto node has been deprecated because of its incompatibility with the AI Modular Behavior Tree system. See down a bit further for info regarding the preferred AISequence nodes and how to use them.

In the Editor perspective viewport, select the Human AI character, then in the "Choose Entity" input port on the AI:GoTo node, right click and "Assign selected entity".

Lastly, you need a position (XYZ), which is where our TagPoint comes in. Select the TagPoint in the viewport, then on the status bar you'll see it's XYZ coordinates:

Enter that into the "pos" input port and your Flow Graph should look something like this (minus the comment box):

Go ahead and hit the AI/Physics button on the status bar and if all has been done correctly thus far, your AI should now walk to the tag point!

Daisy-Chaining Moves

The hardest parts are over! Now you can start layering your logic to extend your AI's abilities. Simple things such as moving to multiple locations a simple thing to do.

On the output ports of the AI:GoTo node, you've got "done", "succeed" and "fail". Copy paste this node (CTRL+C -> CTRL+V) and send the "done" output into the "Sync" input on the second AI:GoTo node.

Instead of manually entering the "pos" for the second node, we're going to make use of our TagPoint. Select the TagPoint in the viewport and then right-click inside the Flow Graph and then "Add Selected Entity".

Now, take the "pos" output from the TagPoint and put it into the "pos" input on the AI:GoTo node. All done correctly, it should look something like this (minus the comment boxes):

Note that the positional coordinates of the TagPoint entity are fed dynamically, meaning you can move this TagPoint via FG then the AI will update its new destination coordinates accordingly. Have some fun and play "carrot on a stick" with the AI by dragging the TagPoint around in the level.

AI:GoTo vs AISequence Nodes

As the CRYENGINE AI system continues to evolve, so does the way you operate AI within Flow Graph. Almost all AI control in Crysis 3 is done through AISequence nodes and that's because of the Modular Behavior Tree that the AI has at its core. If you use an AI:GoTo node, the AI will continue to navigate to its destination, regardless of what happens in the world. Even if an enemy approaches, the AI will continue to walk regardless, this is bad behavior.

Where the AISequence nodes come in, is they are flexible with the AI Modular Behavior Tree. The MBT is a vast and complex set of 'options' the AI is given to cover an array of possibilities within the world. In short, if XYZ happens, do ABC. With this in mind, if you set this Flow Graph up using an AISequence setup, that AI will attempt to reach its destination, but will also take into consideration his MBT, taking cover, shooting from cover, calling for backup, whatever is available to it in that scenario. So it comes down to designer choice. Do you want to force the AI to do this task regardless of environment? Or do you want to allow the AI some more flexibility? In any case, the setup is very similar:

All AISequence's need to start with an AISequence:Start node, which is triggered by, in this case, the Game:Start node. Then once the designer feels this Sequence task is done, finish it off with an AISequence:End node. This will allow the AI to fully resume it's MBT operations.


And there you have it! Controlling AI in CRYENGINE is extremely simple and can be done with as little as two nodes, one being the trigger.

Next, you should start experimenting with controlling multiple AI, working in formations, patrolling areas and then the next big step will be implementing cover and smart objects, which is where things get real interesting!

  • No labels