1.弧度
float angleNew =angle*Mathf.Deg2Rad;
2.
private UnityEngine.AI.NavMeshAgent navAgent;
private Animator anim;
private void Awake() {
navAgent=this.GetComponent<UnityEngine.AI.NavMeshAgent>();
anim=this.GetComponent<Animator>();
}
private void Update() {
//navAgent.desiredVelocity
if(navAgent.desiredVelocity==Vector3.zero){
anim.SetFloat("Speed",0);
anim.SetFloat("AnglarSpeed",0);
}else{
float angle= Vector3.Angle(transform.forward,navAgent.desiredVelocity);
float angleRad=0f;
if(angle>90){
anim.SetFloat("Speed",0);
}else {
angleRad =angle*Mathf.Deg2Rad;
}
Vector3 crossRes=Vector3.Cross(transform.forward,navAgent.desiredVelocity);
if(crossRes.y<0){
angleRad=-angleRad;
}
anim.SetFloat("AnglarSpeed",angleRad);
}
}