[Bug] A*pathfinding Seek task incorrectly success at second call

GeorgeZ

New member
1364
Behavior Tree logic


Note:

1. bool value StopOnTaskEnd has been checked in both seek task.

2. Two seek task has assigned two different gameobject as destination.


Describe:

First seek task works fine. After wait for 5s, the second seek will start. But the task will immediately return success and never move.

I think is because IAstarAI is updating remainingDistance very slow after new destination has been assigned.


My temporary solution:

Change code in IAstarAIMovement.cs
Code:
        protected override void Stop()
        {
            agent.isStopped = true;
            agent.destination = Vector3.positiveInfinity;
            //agent.canMove = false;
        }

        protected override bool HasArrived()
        {
            return agent.reachedDestination || (agent.remainingDistance < arriveDistance.Value && !agent.isStopped);
        }
 

Justin

Administrator
Staff member
Thanks for the repro steps. I think that your solution looks good and I'll make a similar change on my end.
 

KO_Games

New member
My temporary solution:

Change code in IAstarAIMovement.cs
Code:
        protected override void Stop()
        {
            agent.isStopped = true;
            agent.destination = Vector3.positiveInfinity;
            //agent.canMove = false;
        }

        protected override bool HasArrived()
        {
            return agent.reachedDestination || (agent.remainingDistance < arriveDistance.Value && !agent.isStopped);
        }
This fixed my issue I was having too. The remainingDistance goes down to a very low number for example .0000001 when switching targets quickly so the HasArrived always returns as true...and therefore shows as success. Thanks!
 

nathanj

Member
This modification helped me as well. Thanks!

Edit. It worked the first time I tried it but I;m still having trouble changing destination points.

Ah, I think my problem was really trying to use the point graph and the grid graph together. This just resulted in a giant headache. I've found a happy middle ground by using Unity navmesh for the wander type motions and the A* for paths.
 
Last edited:
Top