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;

}

}

相关推荐
计算机魔术师11 小时前
OpenAI 砍掉 100 亿融资目标,AI 资本市场的温度计变了
前端
淡海水11 小时前
09-01-内存-Unity资源生命周期全景
unity·c#·游戏引擎·.netcore·gc
jktantan12 小时前
(二)Vue 3 的 attrs 不是响应式:el-form 扩展属性同步的三种方案
前端·javascript·vue.js·element-plus
前端 贾公子12 小时前
第 5 章:Codex 从可运行程序到可交付工具
java·前端·数据库
用户3600555790012 小时前
Kestrel_VLLM - 26 · 发射空档三步曲:事件计时 → nsys → 判别实验
前端
echome88812 小时前
JavaScript async/await 错误处理:别让 Promise 静默失败
开发语言·前端·javascript·promise
PedroQue9913 小时前
v0.2.0 架构升级:class + reactive 重塑状态管理
前端·uni-app
鶴哥只手遮天13 小时前
Angular 22 源码级深度解析-第 02 章 编译链路总览:从模板字符串到 `ɵɵ` 指令
前端·开源·angular.js
尘世中一位迷途小书童13 小时前
别再堆万字 Prompt:用 Agent Skills 给团队写一个「前端 Review」Skill
前端·ai编程·cursor
aixingpan13 小时前
aixingpan.cn API开发文档:api_docs_bichart_common2接口指南
前端·php