transform.Rotate
时间: 2023-12-12 09:05:36 浏览: 28
Transform.Rotate is a method used in Unity game engine to rotate an object in 3D space.
The syntax for using Transform.Rotate is as follows:
transform.Rotate(Vector3 axis, float angle, Space relativeTo);
The first parameter, Vector3 axis, represents the axis around which the rotation will occur. For example, if you want to rotate an object around the x-axis, you would pass in Vector3.right.
The second parameter, float angle, represents the amount of rotation in degrees.
The third parameter, Space relativeTo, determines whether the rotation is applied in local space (relative to the object's own coordinate system) or world space (relative to the global coordinate system).
Here's an example of how to use Transform.Rotate to rotate an object around the y-axis by 90 degrees in local space:
transform.Rotate(Vector3.up, 90f, Space.Self);