ReachedDestination and ReachedEndOfPath not working?

Hi @aron_granberg! I’m creating path via shift+click.

public override void SetPath(Vector3 destination)
        {
            pathCurrent = ABPath.Construct(AI.position, destination, OnPathComliteSetEndPoint);
            Seeker.StartPath(pathCurrent);
            pathCurrent.BlockUntilCalculated();
        }

        public override void AddToPath(Vector3 destination)
        {
            if (AI.hasPath)
            {

                if (destination != Vector3.zero)
                {
                    pathCurrent = Seeker.GetCurrentPath();
                    pathNew = ABPath.Construct(pathCurrent.vectorPath.GetLast(), destination, OnPathCompliteAddRange);
                    AstarPath.StartPath(pathNew);
                    pathNew.BlockUntilCalculated();
                    //Seeker.StartPath(pathNew);
                }
            }
            else
            {
                SetPath(destination);
            }
        }

callbacks and debug for checking destination

public override void OnPathComliteSetEndPoint(Path p)
        {
            if (p.error)
            {
                Debug.LogWarning("ABPath p.error - " + p.errorLog);
            }
            else
            {
                Seeker.PostProcess(p);
                AI.destination = p.vectorPath.GetLast();
            }

            DebugDestination();
        }

        public override void OnPathCompliteAddRange(Path p)
        {
            if (p.error)
            {
                Debug.LogWarning("ABPath p.error - " + p.errorLog);
            }
            else
            {
                //pathModifier?.Apply(p);
                Seeker.PostProcess(p);
                AI.destination = p.vectorPath.GetLast();
                pathCurrent.vectorPath.AddRange(p.vectorPath);
                DebugDestination();
            }
        }

        void DebugDestination() {
            var point = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            point.transform.position = AI.destination;
        }

but AI.reachedDestination and AI.reachedEndOfPath return true when the unit got first destination.

What I’m doing wrong?

I was trying same on unity store version and on the last one with burst, same results.

vid

Hi

You are mixing setting the ai.destination field and calculating the path yourself.

I would recommend that you never call seeker.StartPath unless you want to completely control all path calculations of the agent (also by setting ai.canSearch = false).

I would instead recommend that you take a look at the Patrol script included in the package. It shows you how to move through a series of points. That particular script just moves through a series of points in a cycle, but you should be able to adjust the behaviour so that the agent follows your shift+clicked points.