Adjusting the current path segment destination

I’m looking at adjusting the way the the pathFollowComponent moves around obstacles to have it account for groups of pawns in it’s path. The basic concept is this:

  1. Get all actors within a radius
  2. Throw out actors who are no in front of you save others to an avoidance array.
  3. Calculate the average location of the group to determine if it is a shorter distance to turn left or right.
  4. Find the furthest actor away in the group in the direction that is in question and save it’s location as a temp destination point
  5. Rotate X degrees (based on distance) to avoid collision with the furthest unit.
  6. Validate that point.
  7. Update it as the new path segment end point.

The only part I’m having trouble finding is changing the path itself. I looked inside UpdatePAthSegment but it only has GetCurrentTargetLocation(); There doesn’t seem to be a Set equivalent. How would I go about modifing the path on the fly? Is it possible to do this in a separate function? I’d like to not ave it on tick and instead on it’s own timer if possible to eliminate large number of units being iterated over each tick.

This would serve as a lighter weight alternative to the Detour Crowd system that would work for our specific purposes where units are the only real dynamic obstacles.

Have you tried using CharacterMovementComponent’s RVO?

Regarding modifying the path, do you really need to do that? If you really want go this route of runtime avoidance maybe you could just override FollowPathSegment or even TickComponent in your custom PathFollowingComponent class, and have AI move in whatever direction you want? Just remember you need to take path’s navigation corridor into account as well, otherwise you may end up steering your AI out of navigable space!



Hey Mieszko, Thanks, I’ve tried RVO but in cases of large groups of AI they tend to be pushed off of the NavMesh all together and detour is a little to heavy as I need hundreds of units performing actions for an RTS game. Even with Detour they get stuck on each other quite easily.

I have been looking at CrowdFollowingComponent for insight but PathFollowingComponent is much simpler to understand (IT actually requests a movement component to move.) I’ll try to approach the same logic through overriding FollowPath.

I haven’t looked into the navigation corridor. I assume this is an area around a path that is considered valid before it is no longer on the path. I looked in the Path Variable but I don’t see anything regarding this. Perhaps you can point me to a doc or some extra reading regarding this?

The navigation corridor can only be found in FNavMeshPath and the best to obtain it is by calling GetPathCorridorEdges - it will retrieve it in a form of a list of portal edges expressed as pairs of FVectors.

Hi Mieszko,

I wanted to follow up on this. I’v created some avoidance logic that accounts for groups of actors within a radius and through some traces, find the edge of the group and move toward it. The problem is that the focus of the actor stays on it’s original goal. so the forward vector does not update. (and thus they are still blocked)

My AIController is calling the initial move with MoveToActor but has strafe disabled. Then to adjust the movement in the pathFollowingComponent I am calling MovementComp->RequestDirectMove but pass it a new point rather than the current target. Is that not the correct way to do it ?

If you’d like I can package up a little project and you can take a look at it.


Can you share your findings in this?
I am about to implement something similar :-0.