Unity3D 中的旋转

标签 rotation transform unity3d euler-angles

这是我正在尝试做的简化代码:

var angle = 1.57;
if ( this.transform.rotation.y > angle ){
  this.transform.rotation.y--;
} else if ( this.transform.rotation.y < angle ){
  this.transform.rotation.y++;
}

我习惯于在 AS3 中编写代码,如果我在 Flash 中编写代码,它可以完美运行,但在 Unity3D 中却没有,而且我很难弄清楚原因,或者我如何才能获得这种效果。

有谁能够帮助我?谢谢!

编辑:

我的对象是一辆带有 2 个胶囊对撞机的刚体汽车,在“崎岖不平”的地板上行驶,在某些时候他只是失去了方向精度,我认为这是因为它是分层旋转系统。

(感谢 kay 的 transform.eulerAngles 提示)

最佳答案

transform.rotation检索 Quaternion .试试 transform.rotation.eulerAngles.y反而。

关于Unity3D 中的旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9319512/

相关文章:

android - 旋转后的TextView : are these problems bugs?

html - css 转换和动画冲突; html元素的顺序很重要吗?

jquery - 让 CSS Transition 发生不止一次?

javascript - 同步 Object3d 旋转(选项卡级别)

ios - 旋转时自动更新 preferredContentSize

C++:围绕平面法线旋转 vector

Javascript,CSS : change transform origin to centerpoint of gesturechange

c# - 受 timeScale 影响的协程 WaitForSeconds

c# - C++ dll 在 C# 代码中抛出 EntryPointNotFoundException

c# - SVGImage在Mapbox的Unity SDK中导致编译器错误