Game Development Reference
In-Depth Information
4.
Just as we added PathNodes to our array for our bots to use, we need to add the
WayPoints that NavMeshes use to our array. Add the PostBeginPlay() function
to your class.
/*=======================================================
* Called right after the map loads
=======================================================*/
simulated function PostBeginPlay()
{
local PathNode Current;
/** Calls all of the PostBeginPlay functions from
parent classes */
super.PostBeginPlay();
// Add the PathNodes to the array
foreach WorldInfo.AllActors(class'Pathnode',Current)
{
WayPoints.AddItem(Current);
}
}
5.
Let's add our Idle state, which informs our bot that we want it to remain still until
it detects another pawn to follow.
This is the first time that we use two states in our class. We use the keyword auto
to denote that this is the state that our pawn will be in as soon as it spawns on the
map. Previously, we told our bot to ignore SeePlayer , but now we want it to be
actively aware of other players on the map. We're setting our target variable to
the first pawn the bot sees. This target variable is what we'll be passing around
to the other functions for finding the location we want our bot to head towards.
/*=======================================================
* We want the pawn to remain still until our player
* crosses its path
=======================================================*/
auto state Idle
{
event SeePlayer (Pawn Seen)
{
super.SeePlayer(Seen);
target = Seen;
/** If our pawn is spotted, go to the function that
follows him */
GotoState('Follow');
}
Begin:
}
 
Search Nedrilad ::




Custom Search