# Adjusting the current path segment destination

**URL:** <https://forums.unrealengine.com/t/adjusting-the-current-path-segment-destination/316004>\
**Category:** AI\
**Tags:** pathfinding, unreal-engine, avoidance, question\
**Created:** [April 22, 2015, 7:47pm UTC](https://forums.unrealengine.com/t/adjusting-the-current-path-segment-destination/316004 "2015-04-22T19:47:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin.Dooley](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/justin.dooley/32/1194553_2.png) [@Justin.Dooley](https://forums.unrealengine.com/u/Justin.Dooley)\
**Post date:** [April 22, 2015, 7:47pm UTC](https://forums.unrealengine.com/t/adjusting-the-current-path-segment-destination/316004/1 "2015-04-22T19:47:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MieszkoZ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MieszkoZ](https://forums.unrealengine.com/u/MieszkoZ)\
**Post date:** [April 22, 2015, 8:18pm UTC](https://forums.unrealengine.com/t/adjusting-the-current-path-segment-destination/316004/2 "2015-04-22T20:18:47Z")

</div>

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!

Cheers,

–mieszko

---

<div class="post-metadata">

**Author:** ![Justin.Dooley](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/justin.dooley/32/1194553_2.png) [@Justin.Dooley](https://forums.unrealengine.com/u/Justin.Dooley)\
**Post date:** [April 22, 2015, 10:17pm UTC](https://forums.unrealengine.com/t/adjusting-the-current-path-segment-destination/316004/3 "2015-04-22T22:17:38Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![MieszkoZ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MieszkoZ](https://forums.unrealengine.com/u/MieszkoZ)\
**Post date:** [April 22, 2015, 10:58pm UTC](https://forums.unrealengine.com/t/adjusting-the-current-path-segment-destination/316004/4 "2015-04-22T22:58:11Z")

</div>

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 `FVector`s.

---

<div class="post-metadata">

**Author:** ![Justin.Dooley](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/justin.dooley/32/1194553_2.png) [@Justin.Dooley](https://forums.unrealengine.com/u/Justin.Dooley)\
**Post date:** [April 28, 2015, 10:05pm UTC](https://forums.unrealengine.com/t/adjusting-the-current-path-segment-destination/316004/5 "2015-04-28T22:05:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Anonymous\_e5d5c0bf7d300728867097ff79906dbe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_e5d5c0bf7d300728867097ff79906dbe](https://forums.unrealengine.com/u/Anonymous_e5d5c0bf7d300728867097ff79906dbe)\
**Post date:** [December 28, 2017, 2:01am UTC](https://forums.unrealengine.com/t/adjusting-the-current-path-segment-destination/316004/6 "2017-12-28T02:01:45Z")

</div>

Hello,

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