CryEngine AI Image 7

CryEngine AI Part II – Your First AI Battle

Step 1

Open the Object Panel of the Rollup Bar (if it’s not already open) and select Entity. Expand the AI separator, and drag a Grunt AI out onto the playing field. You may want to spend extra time rotating him, or the player. You also could leave them facing the same direction, like I did.

CryEngine AI Image 6

Step 2

Since the map’s geometry is complete, we should build the AI paths next. This is simple, but takes a little time. Click on the Menu -> AI -> Generate All AI. You may also want to Generate Triangulation and 3D Navigation Volumes, I’m not certain whether or not they get built or not in the “All AI” build.

Step 3

Hit Escape. Clear your selections.

Step 4

Select the Grunt. It’s time to change his properties. Find the Entity Properties2 Box, expand it. And make sure that the AutoDisable variable is set to False. (It’s default state is True, why I do not know.)

Step 5

Now click on Menu->Game -> Switch to Game. Or hit F12. Or Control + G. Basically, try it out. If everything worked, Grunt should shoot at you. Or at the very least, run you down and deck you. Better than it sounds, trust me.

CryEngine AI Image 7

Step 6

Clone Grunt1, you’ll need 2 separate Factions for this. For the sake of this tutorial I’m using Players (it’s the one which the Player spawns into, and thus our allies) and Grunts. The FACTIONS.XML file is quite simple and located inside the SCRIPTS.PAK. Adding new entries to it should be no problem.

Step 7

Rename Grunt1 to be Enemy_1 or something identifiable (and other than Grunt, as it’s a poor practice to leave things with default names.)

Step 8

For Grunt2, rename him to Ally_1. And inside of Entity Properties, locate the Faction variable. Change it to Players.

Step 9

Enable AI processing inside the Editor. It’s just a button on the bottom of the screen. Once you hit it, they should go to work on each other.

CryEngine AI Image 8

Step 10

Game Mode, round 2. Control + G is my hotkey btw, I don’t really like it (it’s a clumsy stretch) but I see no point in changing it. F12 is too far away from my Keyboard hand anyway… Anyway, when you go in… the AI should shoot each other. Hopefully the one aligned with Grunt still shoots at you.


In Closing

That’s all there is to it. So now we have an AI battle. They will shoot each other. One faction will not shoot the player. Now, if you’re as bad as I am, you probably cloned the heck out of the AIs and watched them fight for hours. You could even build a small environment with some cover for them to use. ( Just remember to rebuild the AI (see Step 2) any time you change the level geometry. )  Heck, I even put a video of this up on YouTube.

0 0 votes
Article Rating
Inline Feedbacks
View all comments
9 years ago

nice tutorial, and also your able to define the Ai variables with in the scripting and game codeing located at the cry dev documentation. There is a few tutorials there about setting up new Ai scripting and altering there behaivers.
although this was very helpful.

10 years ago

Simple and effective! Bravo!

// AIPC.