Vector3 angle = this.transform.localEulerAngles;
private void MovementRotation2(float horizontal, float vertical)
{
//Debug.Log("horizontal "+horizontal+" vertical "+vertical+" "+this.transform.rotation);
//直接让 Z 轴注视旋转,给它一个方向即可。
Quaternion dir = Quaternion.LookRotation(new Vector3(horizontal, 0, vertical));
this.transform.rotation =dir;// Quaternion.Lerp(this.transform.rotation, dir, Time.deltaTime * rotateSpeed);
//this.transform.Translate(0, 0, Time.deltaTime * moveSpeed);
}
private void MovementRotation(float horizontal, float vertical)
{
float xx=0;
float abs=0;
if(vertical<0)abs=180;
if(vertical!=0){
xx=Mathf.Atan(horizontal/vertical)/ Mathf.Deg2Rad;
Debug.Log("ArcTan "+xx);
Debug.Log("ArcTan2 ");
Vector3 NewV3=new Vector3(0, angle.y+xx+abs, 0) ;
this.transform.localEulerAngles = NewV3;
}
}