【问题标题】:How to get an objects rotation in degrees? Unity [duplicate]如何以度数获得对象旋转?团结[重复]
【发布时间】:2020-08-21 21:46:15
【问题描述】:

当我运行这个时: Debug.Log(playerCenter.transform.rotation); 它给出了一个具有四个值的结果。这些值中的每一个都在 -1 和 1 之间。我如何才能获得以度为单位的 x y 和 z 值。

还有第四个值是多少?

【问题讨论】:

标签: c# unity3d game-engine


【解决方案1】:

尝试使用transform.eulerAngles,transform.rotation 返回一个归一化的四元数。四元数也返回 4 个值。 first value you 得到的是围绕另一个向量(其他 3 个值)的旋转。 As this stackoverflow post perfectly saysSo you could think of it as the rotation of the rotation, in simple terms!

【讨论】:

    【解决方案2】:

    你试过playerCenter.transform.rotation.eulerAngle吗?或者playerCenter.transform.eulerAngle。还有关于第四个值,你指的是Quaternion的第四个参数吗?例如Quaternion (float x, float y, float z, float w)?

    【讨论】:

    • 添加 eulerAngles 有效。谢谢! Debug.Log(playerCenter.transform.rotation.eulerAngles.z);
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-12
    • 1970-01-01
    • 2013-10-03
    • 1970-01-01
    • 2018-05-21
    • 2011-11-20
    相关资源
    最近更新 更多