Game Development Reference
* This is where all of the logic occurs
simulated function PathFind()
local int Distance;
/** Distance between our pawn's current location and
PathNode in our array */
Distance = VSize2D(Pawn.Location -
if (Distance <= CloseEnough)
// Head towards a random PathNode in our array
Load our Ch5_PathNodes2.udk map and in your Kismet Actor Factory, set your
controller and pawn to RandomNodeBot and TutorialPawn classes, as this tells
the factory to now spawn those. You can do this by selecting the pull down, which
will list the various classes available to us.
Press the PIE button and play in the editor. Your bot should now patrol from node
How it works...
This was a very straightforward recipe, as we were only required to make changes to one
function for our new functionality. Making use of UDK's Rand() function allowed us to
pick a random PathNode along the array we created when the bot was spawned.
Allowing a pawn to randomly patrol a map
We've been working with bots that operate on maps with PathNodes lately. Sometimes
we may find that NavMeshes better suit our needs. In that case, we'll need a bot who can
wander around a map while pathfinding. This prevents the bot from running into walls and
objects along the way.
If the bot does collide with something along its journey, it will pick a different path.