简体   繁体   中英

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*?

Debug code in Update

Debug.Log(transform.rotation.eulerAngles);

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

Inspector:

在此处输入图像描述

Object in hierarchy

在此处输入图像描述

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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