Movement Pack Seek Task does not use Arrive Distance

psdavis

New member
Project Settings:
- Unity 2019.4.29f1
- A* Pathfinding project
- Behavior Designer
- Movement Pack with A* Pathfinding Project assets downloaded from site.

I have 2 agents in a 3D space. Agent A is setup up to Patrol and when Agent B enters the sight cone of the Can See Object task it switches to the Seek task.
This is all working as it should be.

However, the Arrive Distance variable on the Seek task seems to have no effect. Agent A moves to the same position as Agent B (Target Position) and the Seek task ends with success. I don't want this. I want Agent A to stop 1 Unit away from Agent B.

The Seek task included with the Tutorial download seems to use this value, but this task only works with Unity's NavMesh and I need A* to create the proper agent movement for this project.

I've also looked around the forums and found one issue similar to what I'm experiencing, and the settings of that user had the AI Path component from A*PP.
In my project, I'm using the AI Lerp component as I need that linear movement for my agents.

However, when I tried using the AI Path component as a test, there were two problems;
1) changing the "End Reached Distance" on the AI Path component meant that the Seek task never returned true
2) Arrive Distance still had no effect; I had thought it may "override" the End Reached Distance, but did not. Setting them to the same value also has no effect.

Thank you.
 
When HasArrived is called the Arrived Distance is used to determine if the agent has arrived. Similar to the NavMesh's Stopping Distance, A* also has an arriving parameter which is independent of the Arrived Distance. The Arrived Distance should be greater than the End Reached Distance otherwise it will not complete.

One way to debug this is if the task hasn't stopped running but the agent has stopped moving is to place a breakpoint within the HasArrived method. This will allow you to see why the task thinks that it should still be active.
 
Hi Justin,
Thanks for your reply.
I looked at HasArrived

This node is overriding IAstarAIMovement but is not overriding the HasArrived method.
The parent simply calls this:
Code:
return !agent.pathPending && (agent.reachedEndOfPath || !agent.hasPath);

I looked at the Tutorial's version of Seek, and it has a HasArrived method that looks like this:
Code:
            float remainingDistance;
            if (navMeshAgent.pathPending) {
                remainingDistance = float.PositiveInfinity;
            } else {
                remainingDistance = navMeshAgent.remainingDistance;
            }

            return remainingDistance <= arriveDistance.Value;

So, it would seem the trick is to fix the Movement pack's Seek and override HasArrived to do that check with remainingDistance.
However, I don't know what the equivalent in A* to that would be.
 
Ahh, I just looked at the code and you're right. The A* version of HasArrived has gone through many different iterations and I am hesitant to change it because it seems to be working well.

I will remove the Arrive Distance from the integration since it is no longer used. The task should return success when A* determines that it has arrived so it sounds like something is stopping your agent from getting to its destination.
 
Oh, sorry if that part was unclear.
The Seeking Agent is arriving at the target destination when I use the AI Lerp component, so the task returns success.
That part is no problem. If I use the Seek with the AI Path component, it never returns success, but I'm not using that one so I don't care.

However, the Seeking Agent is *exactly* at the Target's position. I want to set the Arrive Distance to 1.0 so that the Seeking Agent is in the "square" next to the Target.

This project uses Grid-based movement, hence the AI Lerp A*PP component.
 
Last edited:
Ah, thanks for the clarification. Maybe there is a more A* way of doing this, but I would solve this by changing the target so it is in the square next to the real target instead of being at the real target. But like I said, there may be a more A* friendly way of doing this that I am not aware of.
 
Top