Game Development Reference
In-Depth Information
6. Our final addition to this class is in the default properties. We'll add this to all
of our AIController classes, as it tells the game that the pawn is either a player,
or a player-bot.
// Pawn is a player or a player-bot
bIsPlayer = true
We'll need to make some changes to our TutorialPawn class before we can
advance. Because our TutorialPawn class was previously just controlled by us,
we didn't have to worry about falling off ledges. AIControllers will now be using the
pawn, so we need to add some code to instruct it not to fall off the ledges, or the
edge of our map.
In the default properties block for our TutorialPawn.uc file, add these two lines:
bAvoidLedges=true // don't get too close to ledges
bStopAtLedges=true // if bAvoidLedges and
bStopAtLedges, Pawn doesn't try to walk
along the edge at all
Rebuild scripts and start up the editor.
In our Ch5_PathNodes2.udk map and in Kismet, change the player controller to
WanderBot and pawn to use our TutorialPawn. Press the PIE button to play in the
editor and you should see your bot on the map. After one moment he'll begin to
wander from place to place!
How it works...
This is about as simple as bot AI can ever get, and therefore, is an excellent starting point for
us. We're simply taking our bot's current location and then informing the bot of where we want
it to be. This math is done by taking a random integer, clamping the minimum and maximum
values, and then applying it to where we want our bot to be.
After our bot reaches its target location, we then instruct it to wait for 2.5 seconds before
deciding on a new location to reach.
We also found it necessary to add two booleans in the default properties block for our
TutorialPawn, as we want to prevent our pawn from falling off ledges.
Search Nedrilad ::

Custom Search