「Unity」将Vector3转化为Quaternion

重载1:
static Quaternion Euler (float x ,float y,float z)

Description:
Returns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis (in that order).

描述:
返回一个旋转角度,绕z轴旋转z度,绕x轴旋转x度,绕y轴旋转y度(像这样的顺序)。

具体使用代码如下:

//将transform中的rotation修改成(0,30,0)
 Quaternion rotation = Quaternion.Euler(0f, 30f, 0f);
 transform.rotation = rotation;

重载2:
static Quaternion Euler (Vector3 rotationVector3)

Description:
Returns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis (in that order).

描述:
返回一个旋转角度,绕z轴旋转z度,绕x轴旋转x度,绕y轴旋转y度(像这样的顺序)。

具体使用代码如下:

 //将transform中的rotation修改成(0,30,0)
 Vector3 rotationVector3 = new Vector3(0f, 30f, 0f);
 Quaternion rotation = Quaternion.Euler(rotationVector3);
 transform.rotation = rotation;

原创文章,转载请注明出

http://www.cnblogs.com/777777-716/p/5003958.html

posted @ 2015-05-19 09:27  万士辰  阅读(4989)  评论(1编辑  收藏  举报