Game Development Reference
In-Depth Information
class WanderBot extends GameAIController;
We only need one global variable, and that's TargetLocation.
var Vector TargetLocation;
2.
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 */
super.PostBeginPlay();
/** 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.
3.
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
loads
=======================================================*/
event Possess(Pawn inPawn, bool bVehicleTransition)
{
super.Possess(inPawn, bVehicleTransition);
Pawn.SetMovementPhysics();
}
4.
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