void Update () {
var h = Input.GetAxis("Horizontal");
var v = Input.GetAxis("Vertical");
//anim.SetFloat("Speed",v * 2.6f);
//anim.SetFloat("runRotation", h * 2.3f);
//print(Time.timeScale);
//print(h);
if (Mathf.Abs(h) > 0.1f || Mathf.Abs(v) > 0.1f)
{
float newSpeed = Mathf.Lerp(anim.GetFloat("Speed"), 5.6f, moveSpeed * Time.deltaTime);
anim.SetFloat("Speed", newSpeed);
Vector3 targetVec = new Vector3(h, 0, v);
Vector3 currentVec = transform.forward;
print("targetVec:" + targetVec);
print("currentVec:" + currentVec);
float angle = Vector3.Angle(targetVec, currentVec);
print("angle:"+angle);
//if (angle > 180) {
// ...进不来
//}
transform.Rotate(Vector3.up * angle * Time.deltaTime*rotateSpeed);
}
else {
anim.SetFloat("Speed", 0f);
}
}
我print出来都不超过180度