> For the complete documentation index, see [llms.txt](https://axongenesis.gitbook.io/timeflow/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://axongenesis.gitbook.io/timeflow/reference/behaviors/tools/rotator.md).

# Rotator

Stabilizes Euler rotations for smooth interpolation

Unity calculates rotation using [quaternions](https://docs.unity3d.com/ScriptReference/Quaternion.html) which when converting to and from Euler angles may cause data loss resulting in inadvertent flipping or collapsing multiple rotations into a partial one. &#x20;

## Problem

Normally, a user sets an object's rotation in the Transform editor and all appears to be fine. &#x20;

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2F7FPbdEOYoGxlnFPdEOT5%2Fimage.png?alt=media&amp;token=ff98fe03-6df5-4962-8ea0-8e87de68743f" alt=""><figcaption></figcaption></figure>

However, when this value is accessed via script as shown below, it returns a different value:

```
Debug.Log("Rotation:" + transform.localEulerAngles);

OUTPUT: 
Rotation:(357.8, 180.0, 180.0)
```

This is particularly problematic for scripts which read and modify rotation values during Update.&#x20;

## Solution

Rotator solves the problem by storing Euler values separately in a simple component so that it does not rely on getting Euler angles from the Transform. This allows rotations to have any value desired and maintains continuity in animations.&#x20;

<figure><img src="https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2FFUXdthiACJmOyVAi707m%2Fimage.png?alt=media&amp;token=ab1b4214-f761-4218-813e-231c87d0863a" alt=""><figcaption><p>Use the Rotator editor to set Euler rotations without limits. </p></figcaption></figure>

{% hint style="warning" %}
Please note that when Rotator is active, it is no longer possible to directly set the Euler angles in the Transform, since Rotator is controlling it. Instead, use the Rotator editor as shown above to set rotation.
{% endhint %}

{% hint style="info" %}
The Rotator component is applied automatically whenever animating an object's rotation.&#x20;
{% endhint %}

## World Space

When enabled, Euler angles are applied in world space rather than local space. This may be enabled automatically by behaviors that require world space rotation, such as [Look At](/timeflow/reference/behaviors/automation/look-at.md).

## Use Physics

This option should be enabled for any object with a Rigidbody component to interact with physics. When enabled, rotation is applied using [Rigidbody.MoveRotation](https://docs.unity3d.com/ScriptReference/Rigidbody.MoveRotation.html).

{% hint style="info" %}
Rotator has been built into the [AxonGenesisBehavior ](/timeflow/reference/scripting.md#axongenesisbehavior)base class for easier access and setup throughout scripts in Timeflow. Please see Rotator.cs for more info.
{% endhint %}

## Context Menu

Additional commands can be found by clicking the 3 dotted menu on the right side of the inspector.

![](https://2067910529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC3dOuetlQfYgK5FPUKgn%2Fuploads%2F9kxXELxuInkomDrmcwmF%2Fimage.png?alt=media\&token=613ed591-e778-4d53-a243-23f939b1fc98)

### Flip X | Y | Z | All Axes

Applies a 180 degree rotation to the selected axis, or all axes. Use this to flip the orientation of the rotation.

### Invert X | Y | Z | All Axes

Multiplies the axis rotation by -1 to reverse the direction of rotation.

### Round Values

Applies rounding to each axis value, converting them to integer values.

### Wrap 90 | 180 | 360

This constrains rotations to the selected amount of degrees. Instead of clamping values, this wraps the values within the range (negative to positive).
