How can I stop the agent's movement immediately (setting its velocity to zero) with AIPath?

I am using AIPath for movement and have the following method for stopping movement when needed:

public void StopMovement()
    {
        aiPath.isStopped = true;
        aiPath.canSearch = false;
    }

However, sometimes I need to stop the movement immediately (without being affected from smoothing /lerp) by making sure the velocity gets to zero right away. For instance, when the agent goes to a door and interacts with it, the door gives the instruction to face the door but because the velocity from the movement keeps on updating for some time, it does not reflect on the animation. So I need to get the velocity to zero right away before the interaction with the door begins (so the agent can face the door when the instruction comes).

I tried the following two solutions I could think of but none worked. Can you please help?

Tried Solution 1

public void StopMovement(bool stopImmediately = false)
{
        if(stopImmediately) aiPath.maxAcceleration = 10000;
        
        aiPath.isStopped = true;
        aiPath.canSearch = false;

        SetMovementState(CharacterMovementState.Idle);

        StartCoroutine(StopMovementCo());
}

IEnumerator StopMovementCo()
{
        yield return new WaitForSeconds(1f);
        aiPath.maxAcceleration = -2.5f;
}

Tried Solution 2

public void StopMovement(bool stopImmediately = false)
{
        aiPath.isStopped = true;
        aiPath.canSearch = false;
        
        if(stopImmediately)
        {
            aiPath.Move(Vector3.one); // I also tried Vector3.zero
            aiPath.FinalizeMovement(aiPath.position, aiPath.rotation);
        }
}

Hi

Setting ai.canMove = false will make it stop immediately.

If you are using the beta version you can alternatively set
ai.desiredVelocityWithoutLocalAvoidance = Vector2.zero;

However, if you are animating the character and don’t want the AIPath script to interfere a better solution might be to simply disable that component and then enable it once you are done.

Sorry man, this apparently was quite basic. Setting canMove worked like a charm, thank you very much!