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;

}

}

相关推荐
DFT计算杂谈3 小时前
VASP+PHONOPY+pypolymlpj计算不同温度下声子谱,附批处理脚本
java·前端·数据库·人工智能·python
广州华水科技3 小时前
如何选择合适的单北斗变形监测系统来保障水库安全?
前端
Mr_Xuhhh3 小时前
MySQL表的内连接与外连接详解
java·前端·数据库
Amumu121383 小时前
Vue Router(一)
前端·javascript·vue.js
郑州光合科技余经理3 小时前
可独立部署的Java同城O2O系统架构:技术落地
java·开发语言·前端·后端·小程序·系统架构·uni-app
清山博客3 小时前
jQuery easyui 扩展datetimebox控件,增加上午、中午、下午快速选择
前端·jquery·easyui
VT.馒头3 小时前
【力扣】2694. 事件发射器
前端·javascript·算法·leetcode·职场和发展·typescript
life码农3 小时前
HTML文本换行显示几种方法总结
前端·html
强子感冒了3 小时前
CSS基础学习:CSS选择器与优先级规则
前端·css·学习
啟明起鸣4 小时前
【Nginx 网关开发】上手 Nginx,简简单单启动一个静态 html 页面
运维·c语言·前端·nginx·html