运行后,人物与组件分离的图片

nav mesh agent的相关设置


控制运动的部分代码(与老师几乎是一样的,可还是有问题)
Robot Animation脚本中的代码
void Update () {
		if (navAgent.desiredVelocity == Vector3.zero) {//目标方向的的速度是否为零(各方向的速度都为零),到达目标位置
		
			anim.SetFloat ("Speed", 0);
			anim.SetFloat ("RotateSpeed", 0);
		} else {
			//向目标值前进而进行的一系列操作
			float angle = Vector3.Angle (transform.forward, navAgent.desiredVelocity);
			//专门控制速度
			if (angle > 90) {
				anim.SetFloat ("Speed", 0);
			} else {
				
				//获取速度
				Vector3 projection = Vector3.Project (navAgent.desiredVelocity,transform.forward);
				anim.SetFloat ("Speed",projection.magnitude,speedDampTime, Time.deltaTime);
			}
			//控制旋转,把度数转变为弧度
			float rag = 0f;
			rag = angle * Mathf.Deg2Rad;
			//判断向左转,或右转
			Vector3 crossRag = Vector3.Cross (transform.forward,navAgent.desiredVelocity);
			//因为是俯视看的方向,所以为 y 轴
			if (crossRag.y< 0) {
				rag = -rag;
			}
			anim.SetFloat ("RotateSpeed",rag,rotateDampTime, Time.deltaTime);//控制状态机中的值,从而旋转
	}
		anim.SetBool ("isPlayerInsight",sight.isPlayerInsight);
	}
救命啊。。。。好几天了,设置过速度,但也是处于人物追逐圆柱体状态。。。