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;

}

}

相关推荐
SoaringHeart25 分钟前
Flutter进阶:基于 EasyRefresh 的下拉刷新封装 n_easy_refresh_mixin.dart
前端·flutter
IT_陈寒2 小时前
Vite的热更新突然不香了,排查三小时差点砸键盘
前端·人工智能·后端
子兮曰3 小时前
Agency-Agents 深度解析:400+ AI 专家的"梦之队"如何重塑开发工作流
前端·后端·vibecoding
竹林8183 小时前
用 The Graph 查询链上数据实战:从手搓 RPC 到 Subgraph,我的 NFT 项目数据加载快了 10 倍
前端·javascript
妙码生花4 小时前
从 PHP 到 AI + Golang,程序员自救转型手记(十九):点选验证码代码逐行目检
前端·后端·go
Awu12274 小时前
⚡从零开发 Agent CLI(五)实现一个可治理、可扩展的工具系统
前端·人工智能·claude
咪库咪库咪5 小时前
Vue3-生命周期
前端
莪_幻尘5 小时前
你的 AI Skill 越多越蠢?Token 上下文爆炸的求生指南
前端·ai编程
lichenyang4536 小时前
从 has.echo 到异步 API 注册表:一次 ASCF API 回调不触发的排查复盘
前端
林瞅瞅6 小时前
Nuxt3 项目部署 Nginx 防盗链后特定 JS 文件 403 问题修复方案
前端