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;

}

}

相关推荐
Cache技术分享3 分钟前
360. Java IO API - 访问文件系统
前端·后端
小璐资源网13 分钟前
CSS进阶指南:深入解析选择器优先级与继承机制
前端·css
工边页字18 分钟前
为什么 RAG系统里,Embedding成本往往远低于 LLM成本,但很多公司仍然疯狂优化 Embedding?
前端·人工智能·后端
墨渊君19 分钟前
OpenClaw 上手实践: 使用 Docker 从构建到可用全流程指南
前端·agent
冰暮流星21 分钟前
javascript之回调函数
开发语言·前端·javascript
米丘25 分钟前
Rollup 打包工具
前端
We་ct26 分钟前
LeetCode 74. 搜索二维矩阵:两种高效解题思路
前端·算法·leetcode·矩阵·typescript·二分查找
moneyinto27 分钟前
Three.js 必背核心方法
前端
wuhen_n29 分钟前
Vue3 组件中的图片懒加载与渐进式加载
前端·javascript·vue.js
叫回忆29 分钟前
elpis的npm抽离与发布
前端·javascript