Game Development Reference
In-Depth Information
There's more...
There are two console commands which will make you understand how the bots operate
and what is going through their mind.
While playing a game within the editor, press the console key ( ~ or Tab ) to bring up the
console. Enter the command ViewBot to change your perspective to that of the bot.
Type ViewSelf to bring it back to your pawn's camera.
ShoweDebug will display all of the debug features for your pawn. This is extremely useful
for displaying information such as which state your pawn is in, its next goal, a ray trace
toward the next goal, and whether or not it has detected any enemies.
Making a pawn patrol PathNodes on a map
Our movement in the last recipe was very random, but we didn't have much control over
where the bot went. With PathNodes, we can have precise control over where the bot can
and cannot go.
We'll start by creating an AI Controller that allows our bot to wander from PathNode to
PathNode in the order they were laid on the map.
Getting ready
Open your IDE and prepare to create a new class.
How to do it...
We've covered some simple AI up until this point, but now we want to take advantage of the
PathNodes we've laid on a map. In this recipe we'll have our pawns maneuver the map using
the scripts we've written.
1.
Create a new class called PatrolNodeBot and have it extend from UDKBot.
We're extending from UDKBot because we'll need the PathNode functionality
included with it.
class PatrolNodeBot extends UDKBot;
2.
We'll need three variables to go along with it. WayPoints will store our PathNodes
in an array, while _PathNode is the number (integer) of PathNodes on our map.
CloseEnough is an integer that defines how close our pawn needs to be to a node
before it starts looking for a new one.
// PathNode Array
var array<Pathnode> WayPoints;
 
Search Nedrilad ::




Custom Search