首页 > 技术文章 > unity 对象旋转,自转

allyh 2018-06-04 23:03 原文

1.对象具体的围绕哪个轴旋转,对应的设置值;

transform.Rotate(new Vector3(1,0,0));  //绕x轴旋转    //默认是物体围绕世界坐标的XYZ轴旋转,即物体绕着世界中心0,0,0的Y轴进行旋转。该语句相当于transform.Rotate(new Vector3(1,0,0),Space.World);若需要自转,改变该参数即可,栗子transform.Rotate(new Vector3(1,0,0),Space.Self);

2.设置旋转中心,围绕其旋转。

transform.RotateAround(sth.transform.position,Vector3.up,RotateSpeed); 

扩:unity切换场景不销毁对象:DontDestroyOnLoad(gameObject);


推荐阅读