UnrealScript Game Programming Cookbook

(Chris Devlin) #1

AI and Navigation


148

How it works...


The major benefit of using NavMeshes is that they can provide for more natural movements.
Furthermore, they allow for pathfinding if our bot cannot find a direct route to its target. This is
particularly useful for areas where there are a large number of narrow walls, such as a maze.


If our pawn can't find a direct route to its target, whether it is a vector when we are using
the MoveTo() function or actor when we use the MoveToward() function, pathfinding can
automatically generate an efficient route.


By setting a list of constraints, such as avoiding edges of walls or finding a random target,
we can create natural movements and prevent our pawn from getting stuck. Along the way
we have our pawn create a list of points it needs to reach before it can arrive at our target,
in addition to displaying a red sphere at its next destination for debugging purposes.


See also


Additional resources for this chapter can be found at the following locations:


f http://udn.epicgames.com/Three/AIAndNavigationHome.html
f http://romerounrealscript.blogspot.com/2012/04/ai-navigation-
in-unrealscript.html
f http://x9productions.com/blog/?page_id=521
Free download pdf