Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying to create a class that allows my AIController to path find using pathnodes (NOT NavMeshes).

It's doing a swell job of going from point to point in a set order (although I would like for it to be a random patrol at some point), but it gets caught up on collision from time to time. I.E. He'll walk the same set path, and when he runs into the blocks in the middle of the map he continues to rub against them until they finish, and continues on his merry way to the next path node.

How can I prevent this from happening, or at least have him move from the wall if he does a trace and detects that it is there?

It looks like I need to use MoveToward() instead of MoveTo(), as MoveToward allows the pawn to adjust its course during movement. I'm just not sure of how to use those parameters.

Mougli has a decent tutorial on it, but I can't seem to get it to work correctly with my pathnode array.

class PathfindingAIController extends UDKBot;

var array<Pathnode> Waypoints;
var int             _PathNode;          //declare it at the start so you can use it throughout the script
var int             CloseEnough;

simulated function PostBeginPlay()
local PathNode Current;


//add the pathnodes to the array
foreach WorldInfo.AllActors(class'Pathnode',Current)
        Waypoints.AddItem( Current );

simulated function Tick(float DeltaTime)
                        local int Distance;
   local Rotator DesiredRotation;


if (Pawn != None)
    // Smoothly rotate the pawn towards the focal point
    DesiredRotation = Rotator(GetFocalPoint() - Pawn.Location);
    Pawn.FaceRotation(RLerp(Pawn.Rotation, DesiredRotation, 3.125f * DeltaTime, true), DeltaTime);

Distance = VSize2D(Pawn.Location - Waypoints[_PathNode].Location);

if (Distance <= CloseEnough)

    if (_PathNode >= Waypoints.Length)
        _PathNode = 0;

 auto state Pathfinding
if (Waypoints[_PathNode] != None)               // make sure   there is a pathnode to move to
MoveTo(Waypoints[_PathNode].Location);          //move to it
`log("STATE: Pathfinding");

bIsplayer = True
share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.