aiPath.rvoDensityBehavior.reachedDestination returning true at start of movemet

Hello!
I’m facing a problem with the rvoDensityBehavior.reachedDestination property. It is always returning true at the start of the movement, except for the first time or if I order a second movement without finishing the current one.

Maybe the reachedDestination of the rvo takes some time to be false after the start of the movement, but I’ve not been able to get when that happen. This is my current code:

private AIPath movementSystem;

public void SetDestination(Vector3 destination)
    {
        if (movementSystem != null)
        {
            movementSystem.destination = destination;
            movementSystem.SearchPath();

            StopCoroutine(nameof(ObserveDestinationReach));
            StartCoroutine(nameof(ObserveDestinationReach));
        }
    }

IEnumerator ObserveDestinationReach()
    {
        while (movementSystem.pathPending || (!movementSystem.reachedDestination && !movementSystem.rvoDensityBehavior.reachedDestination))
        {
            Debug.Log("Destination not reached");
            yield return null;
        }
        Debug.Log("Destination reached: " + movementSystem.reachedDestination + ", " + movementSystem.rvoDensityBehavior.reachedDestination);
    }

This works for the first movement, but then the next one prints this at the start:

Destination reached: False, True

After checking the docs I’ve tried to add the movementSystem.pathPending to the coroutine condition, hoping the reachedDestination was true only until the path has been calculated, but the result is the same.

I’ve also tried to call movementSystem.rvoDensityBehavior.ClearDestinationReached() before starting the coroutine, but it didn’t work either.

Am I doing something wrong or is this a bug?

I am using last beta version: 4.3.73, although this also happened to me in version 4.3.48.

Hi

That’s odd. There’s code specifically for setting the rvoDensityBehavior.reachedDestination field to false after the destination property is changed. It will set that field to false unless the new destination is very close to the old one. How far away is the new destination?

Hi, thanks for answering Aron.

Distance doesn’t seem to matter, I’ve just tested it and the result is the same setting the destination point far away. I’ve modified the code to print the current position and the destination when set:

public void SetDestination(Vector3 destination)
    {
        if (movementSystem != null)
        {
            Debug.Log("Current Position: " + transform.position);
            Debug.Log("Destination: " + destination);
            movementSystem.destination = destination;
            movementSystem.SearchPath();

            StopCoroutine(nameof(ObserveDestinationReach));
            StartCoroutine(nameof(ObserveDestinationReach));
        }
    }

This is the result (all printed as soon as the movement starts):

Current Position: (-21.94, -43.13, 0.00)
Destination: (-142.79, 10.24, 0.00)
Destination not reach
Destination reach: False, True

Hello @aron_granberg,
Is there anything else that could be causing this problem? Is this a bug in the library or is it something in my configuration?

Thanks

hello, are you using pool manager or something like that, plz try set the destination like below, see if it works, @Jaime_Alcantara

protected override void OnDisable()
{
base.OnDisable();
destination = new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity);
}

this is the problem i have got

I have also encountered this problem, if you solve it, can you share your solution with me

Once the destination is set, an OnDestinationChanged is performed, setting reachedDestination to fasle, but then an Update is performed, setting reachedDestination to true again. In the example I learned that this seems to be caused by multiple threads. But my project that uses single threads still performs an Update after setting the destination, setting reachedDestination to true, I wonder why