Game Development Reference
In-Depth Information
How to do it...
We've covered enough wandering and patrolling up to this point. Why not create an AI which
is more friendly, and can follow us around a map? I'm sure you've played a game where one
character follows another, whether it is the shadow ninjas in Ninja Gaiden on the NES, or the
president's daughter following Leon in the more recent Resident Evil franchise. Ever wonder
how the characters do that? It's time to explain how.
Create a new class called FollowBot . Have it extend from AI Controller .
class FollowBot extends AIController;
We're going to need four variables for this one. Some of them we've already seen
from previous examples, but they are all pretty well explained in the comments.
/** Whatever target we'd like to use. In this case, our
pawn */
var Actor target;
/** The temporary destination the pawn will be headed
(PathFinding) */
var() Vector TempDest;
/** PathNode Array */
var array<Pathnode> WayPoints;
/** Distance our pawn needs to get to the node before it
looking for a new one */
var int CloseEnough;
Add the event for Possess , just as we've done with our other bots.
* Forces the pawn to begin moving as soon as the map
event Possess(Pawn inPawn, bool bVehicleTransition)
super.Possess(inPawn, bVehicleTransition);
Search Nedrilad ::

Custom Search