# Rotate

> Applies a rotation of eulerAngles.z degrees around the z-axis, eulerAngles.x degrees around the x-axis, and eulerAngles.y degrees around the y-axis (in that order).

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## Rotate(Vector3, Space)

Applies a rotation of eulerAngles.z degrees around the z-axis, eulerAngles.x degrees around the x-axis, and eulerAngles.y degrees around the y-axis (in that order).

```csharp
public void Rotate(Vector3 eulers, Space relativeTo)
```

### Parameters

**** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)): The rotation to apply in euler angles.**** (\[Space]\(/engine/6000.5/script-reference/unityengine/space)): Determines whether to rotate the GameObject either locally to  the GameObject or relative to the Scene in world space.

### Remarks

Rotate takes a [Vector3](/engine/6000.5/script-reference/unityengine/vector3.md) argument as an Euler angle. The second argument is the rotation axes, which can be set to local axis ([Space.Self](/engine/6000.5/script-reference/unityengine/space/self.md)) or global axis ([Space.World](/engine/6000.5/script-reference/unityengine/space/world.md)). The rotation is by the Euler amount.

## Rotate(Vector3)

Applies a rotation of eulerAngles.z degrees around the z-axis, eulerAngles.x degrees around the x-axis, and eulerAngles.y degrees around the y-axis (in that order).

```csharp
public void Rotate(Vector3 eulers)
```

### Parameters

**** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)): The rotation to apply in euler angles.

### Remarks

The rotation is relative to the GameObject's local space ([Space.Self](/engine/6000.5/script-reference/unityengine/space/self.md)).

## Rotate(float, float, float, Space)

The implementation of this method applies a rotation of `zAngle` degrees around the z axis, `xAngle` degrees around the x axis, and `yAngle` degrees around the y axis (in that order).

```csharp
public void Rotate(float xAngle, float yAngle, float zAngle, Space relativeTo)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Degrees to rotate the GameObject around the X axis.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Degrees to rotate the GameObject around the Y axis.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Degrees to rotate the GameObject around the Z axis.**** (\[Space]\(/engine/6000.5/script-reference/unityengine/space)): Determines whether to rotate the GameObject either locally to the GameObject or relative to the `Scene` in world space.

### Remarks

Rotate can have the euler angle specified in 3 floats for x, y, and z.

The example shows two cubes: one cube uses [Space.Self](/engine/6000.5/script-reference/unityengine/space/self.md) (the local space and axes of the [GameObject](/engine/6000.5/script-reference/unityengine/gameobject.md)) and the other uses [Space.World](/engine/6000.5/script-reference/unityengine/space/world.md) (the space and axes in relation to the Scene). They are both first rotated 90 in the X axis so they are not aligned with the world axis by default. Use the xAngle, yAngle and zAngle values exposed in the inspector to see how different rotation values apply to both cubes. You might notice the way the cubes visually rotate is dependant on the current orientation and Space option used. Play around with the values while selecting the cubes in the scene view to try to understand how the values interact.

### Examples

```csharp
using UnityEngine;

// TransformHandle.Rotate example
//
// This script creates two different cubes: one red which is rotated using Space.Self; one green which is rotated using Space.World.
// Add it onto any GameObject in a scene and hit play to see it run. The rotation is controlled using xAngle, yAngle and zAngle, modifiable on the inspector.

public class ExampleScript : MonoBehaviour
{
    public float xAngle, yAngle, zAngle;

    private GameObject cube1, cube2;

    void Awake()
    {
        TransformHandle cube1TransformHandle = cube1.transformHandle;
        TransformHandle cube2TransformHandle = cube2.transformHandle;

        cube1 = GameObject.CreatePrimitive(PrimitiveType.Cube);
        cube1TransformHandle.position = new Vector3(0.75f, 0.0f, 0.0f);
        cube1TransformHandle.Rotate(90.0f, 0.0f, 0.0f, Space.Self);
        cube1.GetComponent<Renderer>().material.color = Color.red;
        cube1.name = "Self";

        cube2 = GameObject.CreatePrimitive(PrimitiveType.Cube);
        cube2TransformHandle.position = new Vector3(-0.75f, 0.0f, 0.0f);
        cube2TransformHandle.Rotate(90.0f, 0.0f, 0.0f, Space.World);
        cube2.GetComponent<Renderer>().material.color = Color.green;
        cube2.name = "World";
    }

    void Update()
    {
        cube1.transformHandle.Rotate(xAngle, yAngle, zAngle, Space.Self);
        cube2.transformHandle.Rotate(xAngle, yAngle, zAngle, Space.World);
    }
}
```

## Rotate(float, float, float)

The implementation of this method applies a rotation of `zAngle` degrees around the z axis, `xAngle` degrees around the x axis, and `yAngle` degrees around the y axis (in that order).

```csharp
public void Rotate(float xAngle, float yAngle, float zAngle)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Degrees to rotate the GameObject around the X axis.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Degrees to rotate the GameObject around the Y axis.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Degrees to rotate the GameObject around the Z axis.

### Remarks

Use TransformHandle.Rotate to rotate GameObjects in a variety of ways. The rotation is often provided as an Euler angle and not a Quaternion.

You can specify a rotation in world axes or local axes.

World axis rotation uses the coordinate system of the `Scene`, so when you start rotate a [GameObject](/engine/6000.5/script-reference/unityengine/gameobject.md), its x, y, and z axes are aligned with the x, y, and z world axes. So if you rotate a cube in world space, its axes align with the world. When you select a cube in the Unity Editor’s `Scene` view, rotation `Gizmos` appear for the left/right, up/down and forward/back rotation axes. Moving these `Gizmos` rotates the cube around the axes. If you de-select and then re-select the cube, the axes restart in world alignment.

Local rotation uses the coordinate system of the [GameObject](/engine/6000.5/script-reference/unityengine/gameobject.md) itself. So, a newly created cube uses its x, y, and z axis set to zero rotation.  Rotating the cube updates the rotation axes.  If you de-select and the re-select the cube, the axes are shown in the same orientation as before.

![TransformRotate1 (Rotate)](/api/media?file=/engine/6000.5/media/images/TransformRotate1.png)

*A cube not rotated in Local Gizmo Toggle*

![TransformRotate2 (Rotate)](/api/media?file=/engine/6000.5/media/images/TransformRotate2.png)

*A cube rotated in Local Gizmo Toggle*

![TransformRotate3 (Rotate)](/api/media?file=/engine/6000.5/media/images/TransformRotate3.png)

*A cube not rotated in Global Gizmo Toggle*

![TransformRotate4 (Rotate)](/api/media?file=/engine/6000.5/media/images/TransformRotate4.png)

*A cube rotated in Global Gizmo Toggle*

For more information on Rotation in Unity, refer to [Controlling rotation with the Quaternion class](/engine/6000.5/manual/scripting/programming-math/unity-engine-math/class-quaternion.md).

The rotation is relative to the GameObject's local space ([Space.Self](/engine/6000.5/script-reference/unityengine/space/self.md)).

## Rotate(Vector3, float, Space)

Rotates the object around the given axis by the number of degrees defined by the given angle.

```csharp
public void Rotate(Vector3 axis, float angle, Space relativeTo)
```

### Parameters

**** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)): The axis to apply rotation to.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The degrees of rotation to apply.**** (\[Space]\(/engine/6000.5/script-reference/unityengine/space)): Determines whether to rotate the GameObject either locally to the GameObject or relative to the Scene in world space.

### Remarks

Rotate has an axis, angle and the local or global parameters. The rotation axis can be in any direction.

## Rotate(Vector3, float)

Rotates the object around the given axis by the number of degrees defined by the given angle.

```csharp
public void Rotate(Vector3 axis, float angle)
```

### Parameters

**** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)): The axis to apply rotation to.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The degrees of rotation to apply.

### Remarks

Rotate has an axis, angle and the local or global parameters. The rotation axis can be in any direction. The rotation is relative to the GameObject's local space ([Space.Self](/engine/6000.5/script-reference/unityengine/space/self.md)).
