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;

}

}

相关推荐
用户39051332192882 分钟前
JS判断空值只知道“||”?不如来试试这个操作符
前端·javascript
海云前端12 分钟前
前端面试必问 asyncawait 到底要不要加 trycatch 90% 人踩坑 求职加分技巧揭秘
前端
wuk9981 小时前
梁非线性动力学方程MATLAB编程实现
前端·javascript·matlab
XiaoYu20021 小时前
第11章 LangChain
前端·javascript·langchain
霉运全滚蛋好运围着转1 小时前
启动 Taro 4 项目报错:Error: The specified module could not be found.
前端
cxxcode2 小时前
前端模块化发展
前端
不务正业的前端学徒2 小时前
docker+nginx部署
前端
不务正业的前端学徒2 小时前
webpack/vite配置
前端
hhcccchh2 小时前
学习vue第八天 Vue3 模板语法和内置指令 - 简单入门
前端·vue.js·学习
yyf198905252 小时前
Vue 框架相关中文文献
前端·javascript·vue.js