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;
}
文章来源:https://www.toymoban.com/news/detail-707281.html
}文章来源地址https://www.toymoban.com/news/detail-707281.html
到了这里,关于untiy horizontal 、vertical 计算角度增量的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!