Game Development Reference
In-Depth Information
class WanderBot extends GameAIController;
We only need one global variable, and that's TargetLocation.
var Vector TargetLocation;
We'll need to override the GameAIController's PostBeginPlay() function and add
the SetTimer() function. This tells our pawn to run the MoveRandom() function
every 2.5 seconds. Without this, our bot would constantly be searching for a new
target location without ever taking a break.
* Called right after the map loads
simulated event PostBeginPlay()
/** Calls all of the PostBeginPlay functions from
parent classes */
/** Frequency at which the bot will begin looking for a
new path */
SetTimer(2.5, true,'MoveRandom');
The timer creates a more natural movement. For example, if you wanted your bot to
move to a random location, and twiddle his thumbs for 5 seconds before contusing,
this function is what would allow that to happen.
The Possess event tells our pawn to begin moving as soon as the map loads.
SetMovementPhysics() is key here, as it automatically makes the pawn walk.
Without this our pawn would need some sort of impulse, such as receiving damage,
before moving.
* Forces the pawn to begin moving as soon as the map
event Possess(Pawn inPawn, bool bVehicleTransition)
super.Possess(inPawn, bVehicleTransition);
We need a function to handle all of the math for where our bot currently is, and
where we want it to be. We're using local variables for the offset, as we won't need
them outside of this function.
Search Nedrilad ::

Custom Search