Game Development Reference
In-Depth Information
// Calls all of the Tick functions from parent classes
super.Tick(DeltaTime);
// If there is a pawn on the map....
if (Pawn != None)
{
/** Then call this method, which initializes our
Pathfinding*/
PathFind();
}
}
The PathFind() function is where all of the math for our pathfinding occurs.
We're making use of that Distance variable (integer), and defining it as the
difference in distance between our bot's current location and the location of
the PathNodes in our array.
If we are within a predetermined distance (the CloseEnough variable), then
we instruct the bot to move towards the next node in the array, as noted by _
PathNode++; . If we've iterated through each of the nodes, then start back
at 0. Once that is done we move to the PathFinding state .
/*=======================================================
* The meat-and-potatoes of the class.
* This is where all of the logic occurs
=======================================================*/
simulated function PathFind()
{
local int Distance;
/** Distance between our pawn's current location and
the next
PathNode in our array */
Distance = VSize2D(Pawn.Location -
WayPoints[_PathNode].Location);
if (Distance <= CloseEnough)
{
// Interate through the next node in our array
_PathNode++;
}
// If we've gone through all of the nodes in our
//array...
if (_PathNode >= WayPoints.Length)
 
Search Nedrilad ::




Custom Search