Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
Transform.eulerAngles 欧拉角
# [Transform](Transform.html).eulerAngles 欧拉角 var *eulerAngles* : [Vector3](../Vector3/Vector3.html) *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.Rotate](Transform.Rotate.html) instead. 仅使用者这个变量读取和设置角度到绝对值。不要递增它们,当超过角度 360 度,它将失败。使用 [Transform.Rotate](Transform.Rotate.html) 替代。 * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { public float yRotation = 5.0F; void Update() { yRotation += Input.GetAxis("Horizontal"); transform.eulerAngles = new Vector3(10, yRotation, 0); } public void Awake() { print(transform.eulerAngles.x); print(transform.eulerAngles.y); print(transform.eulerAngles.z); } } ``` ``` // 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](Transform.rotation.html) 不要分别设置欧拉角其中一个轴(例如: eulerAngles.x = 10; ),因为这将导致偏移和不希望的旋转。当设置它们一个新的值时,要同时设置全部,如上所示。Unity 会从 [Transform.rotation](Transform.rotation.html) 这个四元组结构中转换角度到欧拉角的表达方式,或者反过来。
da
2022年5月23日 14:48
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码