简体   繁体   English

检查员和代码中的不同角度 - 统一

[英]Different angle in inspector and in code - unity

I have a problem understanding rotation in unity.我在理解统一旋转时遇到问题。 Why is the rotation in the inspector not the same as the rotation in the code.为什么检查器中的旋转与代码中的旋转不一样。 And why Y and Z is 180*?为什么 Y 和 Z 是 180*?

Debug code in Update更新中的调试代码

Debug.Log(transform.rotation.eulerAngles);

// Same thing with rigidbody
Debug.Log(_rigidbody.rotation.eulerAngles);

Inspector:检查员:

在此处输入图像描述

Object in hierarchy等级Object

在此处输入图像描述

in the inspector the local euler angles are showed, in your code it's absolute euler angle.在检查器中显示局部欧拉角,在您的代码中它是绝对欧拉角。

use localEuler angle instead if you want to get same result with inspector.如果您想获得与检查器相同的结果,请改用 localEuler angle。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM