NavmeshAgent上の速度検出

 

Rigidbody.veocity.magnitude で速度は出ません

using UnityEngine;
using System.Collections;

public class enemyScript : MonoBehaviour {

	public NavMeshAgent eneCharaObj;
	public Animator enemyAnim;

	float enemySpeedFloat = 0f;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		enemySpeedFloat = eneCharaObj.velocity.sqrMagnitude;
		enemyAnim.SetFloat("enemySpeed", enemySpeedFloat);
		//Debug.Log (enemySpeedFloat);
	}
}