unity RotateAround

一个物体围着另一个物体旋转使用transform组件中RotateAround;

function RotateAround(point:Vector3,axis:Vector3,angle: float) : void

Rotates the transform about axis passing through point in world coordinates

by angle degrees.

按照angle度通过在世界坐标的point轴旋转物体。

简单的说,按照多少度在世界坐标的某位置轴旋转物体。

This modifies both the position and the rotation of the transform.

这个修改变换的位置和旋转角度。

实验C#方法

方法一:

public Transform _Sphere;//引入小球

//围绕着小球为中心,每秒1度物体围着小球

transform.RotateAround(_Sphere.position, new  Vector3(0, 1, 0),1);

方法二:简化之后性能会更好,代码执行效率高

//围绕着小球为中心,每秒1度物体围着小球

public Transform _Sphere;//引入小球

transform.RotateAround(_Sphere.position,Vector3.up, 1);  


实验JS方法

function Update() {// Spin the object around the world origin at 20 degrees/second.

//围绕世界坐标原点,每秒20度物体自旋

transform.RotateAround(Vector3.zero,Vector3.up, 20 *Time.deltaTime);

}

你可能感兴趣的:(unity RotateAround)