Transform.eulerAngles 欧拉角

var eulerAngles : Vector3

Description描述

The rotation as Euler angles in degrees.

旋转作为欧拉角度。

The x, y, and z angles represent a rotation z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis (in that order).

x、y、z角代表绕z轴旋转z度,绕x轴旋转x度,绕y轴旋转y度(这个顺序)。

Only use this variable to read and set the angles to absolute values. Don't increment them, as it will fail when the angle exceeds 360 degrees. Use Transform.Rotateinstead.

仅使用者这个变量读取和设置角度到绝对值。不要递增它们,当超过角度360度,它将失败。使用Transform.Rotate替代。

// Print the rotation around the global X Axis
//打印绕世界x轴的旋转角度
print (transform.eulerAngles.x);
// Print the rotation around the global Y Axis
//打印绕世界y轴的旋转角度
print (transform.eulerAngles.y);
// Print the rotation around the global Z Axis
//打印绕世界z轴的旋转角度
print (transform.eulerAngles.z);

// Assign an absolute rotation using eulerAngles
//指定一个绝对使用欧拉角的旋转角度
var yRotation : float = 5.0;
function Update () {
    yRotation += Input.GetAxis("Horizontal");
    transform.eulerAngles = Vector3(10, yRotation, 0);

}

Do not set one of the eulerAngles axis separately (eg. eulerAngles.x = 10; ) since this will lead to drift and undesired rotations. When setting them to a new value set them all at once as shown above. Unity will convert the angles to and from the rotation stored in Transform.rotation

不要分别设置欧拉角其中一个轴(例如: eulerAngles.x = 10; ),因为这将导致偏移和不希望的旋转。当设置它们一个新的值时,要同时设置全部,如上所示。Unity会从Transform.rotation这个四元组结构中转换角度到欧拉角的表达方式,或者反过来。

转载于:https://www.cnblogs.com/vincentDr/p/3699872.html

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值