untiy horizontal 、vertical 计算角度增量

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;

}

}

相关推荐
Jackson@ML24 分钟前
用ASP.NET创建一个Blazer Web应用程序
前端·asp.net·blazor
shepherd12642 分钟前
Vue-Vben-Admin 从入门到实战:后端开发的前端探索之旅
前端·javascript·vue.js
CircleMouse1 小时前
介绍几个axios接口请求顺序的问题
开发语言·前端·javascript·ecmascript
o***Z4482 小时前
React自然语言
前端·react.js·前端框架
J***Q2922 小时前
React部署方案详解
前端·react.js·前端框架
q***R3082 小时前
React组件性能分析
前端·react.js·前端框架
5***79002 小时前
React趋势
前端·react.js·前端框架
1***y1782 小时前
React路径
前端·react.js·前端框架
m***D2862 小时前
React生态系统
前端·react.js·前端框架
b***74882 小时前
React计算机
前端·react.js·前端框架