navAgent.velocity input returns NaN

Hi all

Here is a script I have attached to a navAgent to navigate a mesh.
using UnityEngine;
using System.Collections;
using BehaviorDesigner.Runtime;
using UnityEngine.AI;

public class MovementScript : MonoBehaviour
{
    //link to Animator component
    public Animator animController;
    //used to set anim controller parameters
    public enum MoveState { Idle,Walking,Attack}
    public MoveState moveState;
    //link to NavMeshAgent component
    public NavMeshAgent navAgent;
    public BehaviorTree behaviorTree;
    private bool canSeePlayer;
    private bool canAttack;
    public float damageAmount;
   

    public void Start()
    
    {
        canSeePlayer = ((SharedBool)behaviorTree.GetVariable("Chase")).Value;
        canAttack = ((SharedBool)behaviorTree.GetVariable("Attack")).Value;             
       
    }
     
    // Update is called once per frame
    void Update()
    {
        //character walks if there is a navigation path set, idle all other times
        canSeePlayer = ((SharedBool)behaviorTree.GetVariable("Chase")).Value;
        canAttack = ((SharedBool)behaviorTree.GetVariable("Attack")).Value;
        


        if (canSeePlayer)

        {
            moveState = MoveState.Walking;
            print(moveState);
            print("I see you!");

            if (canAttack)
            {
                print("Attacking you!");
                moveState = MoveState.Attack;

            }


        }
        else
        {
            moveState = MoveState.Walking;
        } 
                
        //send move state info to animator controller
        animController.SetInteger("MoveState", (int)moveState);

    }
    void OnAnimatorMove()
    {
        navAgent.updateRotation = false;
        //only perform if walking
        if (moveState == MoveState.Walking)
        {
            print("In OnAnimatorMove Function");
            print(navAgent.velocity);
            //set the navAgent's velocity to the velocity of the animation clip currently playing
            navAgent.velocity = animController.deltaPosition / Time.deltaTime;

            //smoothly rotate the character in the desired direction of motion
            Quaternion lookRotation = Quaternion.LookRotation(navAgent.desiredVelocity);
            transform.rotation = Quaternion.RotateTowards(transform.rotation, lookRotation, navAgent.angularSpeed * Time.deltaTime);
        }
    }

    

}

I am getting an error in the navAgent.velocity=animController.deltaPosition/Time.deltaTime;
line saying that the navAgent.velocity is NaN

I am not sure what is causing this and need some help.

Thanks

From the docs:

Animator.applyRootMotion must be enabled for deltaPosition to be calculated

Are you applying root motion with your Animator? If not, that is probably your NaN.

I read the docs in your link and it mentions that when using OnAnimatorMove(), that Animator.applyRootMotion won’t have an effect.

I am using OnAnimatorMove() in my script.

link text