richAI.velocity has value after reachedDestination

I’m building up a simple AI and notice that when reachedDestination becomes true, the richAI.velocity remains positive even though the agent no longer moves. The only way i can get it back to being zero is to disable/enable the RichAI component.

I’m not using the astar beta.


How much are we talking about? It might contain a very very small value.

It’s around .35 which is very noticeable since that velocity is driving my animator which is triggering the walk threshold of .25.

That’s odd. Are you setting ai.canMove = false, or disabling the agent’s movement calculations in some other way?

I’m using the Opsive Behaviour Designer astar implementation, which in their Movement base class has these methods:

        protected override bool SetDestination(Vector3 target)
            agent.canSearch = true;
            agent.canMove = true;
            agent.destination = target;
            return true;

        protected override void Stop()
            agent.destination = transform.position;
            agent.canMove = false;
            agent.canSearch = false;

        protected override bool HasArrived()
            return agent.reachedDestination;
            //return !agent.pathPending && (agent.reachedEndOfPath || !agent.hasPath);

And then my beahviour tasks are doing simple things like:

            if (HasArrived())
                return TaskStatus.Success;

            this.prevTargetPosition = this.targetPosition;


Outside of that I’m building on your demo RichAI bot demo script which uses the agent velocity to set the animator speed parameter which is where I’m seeing the velocity problem after the agent HasArrived in a behaviour task where I do call Stop() so it is setting agent.canMove = false in that method.


When setting canMove = false the agent will stop its movement calculations completely. It will disable all movement code, including the code which updates the velocity. That’s probably why it is not up to date. I’d recommend not setting canMove = false and just letting the agent stay at the destination by itself while still being active.