GDD 011 : Beginner’s Guide To Enemy AI - a podcast by Brian McRae and Ike Herman: Indie Game Developers, Designers, Podcasters

from 2014-04-07T23:11:58

:: ::

Crash course in how to set up AI for your game, complete with pro tips from our resident AI programming expert, Ike.

GDC 2014 has come and gone, we give a little recap of our highlights of the conference. The most exciting part was after Brian's speech at the Unity Booth fans from this podcast came up and talked to us. So just wanted to give a shout out to those that approached us, Thank you!

In other news, Brian's company Fenix Fire will launch a Kickstarter campaign for"Source"which will be available for Xbox 1, PS4, and Steam Greenlight for PC. We want to be as transparent as possible so you can learn from this experience. We'll be showing and discussing the approach, marketing, press, social media, numbers and much more. This is an exciting an unmarked territory challenge and we're looking forward to sharing it with you.
Enemy AIThis podcast is a beginner's guide on how to set up a basic enemy character and how to organize basic functionality. Ike uses his 15 years of experience and gives some black belt examples and ideas while Brian keeps it on a simpler level so wherever your skill level is this will be a helpful podcast for your game development.

3 Key Elements of Enemy AIGoals
MovementResponding to player

GoalsFirst split up behavior between unconscious decisions and conscious decisions. Separate your actions, behaviors and animations into which category it's going to be in and understand the unconscious decisions take priority over the conscious decisions.

A good exercise when starting out is to write down all the conscious and unconscious actions that you're Enemy AI will do. Keep it at a high level.

Conscious DecisionsPatrol - trying to find the player, but not necessarily seeking them out
Idle - waiting for something to happenMoving - to a specific location
Attack - aggressively of lightlyGive a sense of urgency  to each goal this allows you to swap in different animations later and when you have the character respond the same for starters it also gives flexibility later on. However, different states of urgency is more of an advanced feature, the next layer so to speak but it's one that has to be developed early on because it's hard to add later and it creates a more life like complex character for human behavior.

Unconscious Decisions:Hit reaction - hit by bullet
Falling - fell off a ledgeThrown on the ground
Death SequenceThe character doesn't think about what's happening to them, they're a victim of the environment

Step by Step in UnityNext, we go though a detailed explanation of diving in and creating an example using Unity.

Here are some definitions and explanations of terms we've used:

Pathfinding: Basically the study of how do you get from one location to the other when the direct path is unavailable.Character Controller: Certain kind of entity that you can put on to an object and it all of a sudden assumes and absorbs a lot of the nice functionality for moving characters around.

Ray Cast: Imaging looking through binoculars or a telescope and you're looking down a very pinpoint vision, a cone of vision but can see very very far and anything that is interrupting that can be sensed because you're using a ray cast. Basically you pass in a starting positions and an ending position in 3 dimensional space and the first thing that it comes in contact with from the starting position you can get data on it.

Switch Case Functions: A little bit different than an if then statement in programmer talk. Brian gives a detailed example of how he uses this with his Enemy AIHelpful Advice
We're big believers in tracking and recording the state changes of your NPC. Create a change state function and have all the state changes go through there then put it out to your debug window to always have it around. Because one thing with AI is it's really hard to reproduce the same situation over again sometimes and it's a really good idea to ...

Further episodes of The Game Design Dojo Podcast

Further podcasts by Brian McRae and Ike Herman: Indie Game Developers, Designers, Podcasters

Website of Brian McRae and Ike Herman: Indie Game Developers, Designers, Podcasters