「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;
原创文章,转载请注明出
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步