# Animator

> Aego 0.12.5 · development; docs build `4a32b816933e02930662f6a443cb25abe6050d090c55e237cbff5c44ae9b25f8`. [Build manifest](/docs-build.json).

```
component animation.Animator
```

Plays the states of an animation controller and blends between them when its parameters change. The graph, the blends, root motion and gameplay events run on fixed steps, so replays match at any frame rate.

## Fields

| Name | Script name | Type | Default | Description |
|---|---|---|---|---|
| Controller | `Controller` | `AnimController` | `none` | Controller with the states, parameters and transitions. |
| Play On Start | `PlayOnStart` | `bool` | `true` | Enters the entry state when Play starts. |
| Speed | `Speed` | `float` | `1` | Multiplies the speed of every state; 1 is normal speed. |
| Time Domain | `TimeDomain` | `enum` | `game` | game follows game time and pauses with it; unscaled runs in real time while paused, for presentation only. |
| Root Motion | `RootMotion` | `enum` | `none` | What the root track moves: none ignores it, toMotion moves the node through Motion 2D so walls stop it, toTransform sets its position. |
| Root Fallback | `RootFallback` | `bool` | `false` | toMotion moves the transform instead when the node has no Motion 2D. |
| Root Scale | `RootScale` | `Vec2` | `(1, 1)` | Multiplies root motion in the node's parent space; set X to -1 while the character faces left. |
| State | `State` | `string` | `""` | Runtime state. Current state. |
| Time | `Time` | `float` | `0` | Runtime state. Seconds in the current state. |
| Progress | `Progress` | `float` | `0` | Runtime state. Time in the current state divided by the length of its clip; 1 is one full clip. |
| Blending | `Blending` | `bool` | `false` | Runtime state. Whether a transition is blending. |

## CrossFade

```
func (Animator) CrossFade(state string, seconds float)
```

Blends into a state over some seconds, starting on the next fixed step.

## GetBool

```
func (Animator) GetBool(name string) bool
```

Reads a bool or trigger parameter.

## GetFloat

```
func (Animator) GetFloat(name string) float
```

Reads a float parameter.

## GetInt

```
func (Animator) GetInt(name string) int
```

Reads an int parameter.

## IsState

```
func (Animator) IsState(state string) bool
```

Reports whether the animator is in a state; during a blend that is the state it blends into.

## Play

```
func (Animator) Play(state string)
```

Switches to a state on the next fixed step, without a blend.

## ResetTrigger

```
func (Animator) ResetTrigger(name string)
```

Clears a trigger that has not fired yet.

## SetBool

```
func (Animator) SetBool(name string, value bool)
```

Sets a bool parameter; transitions read it on the next fixed step.

## SetFloat

```
func (Animator) SetFloat(name string, value float)
```

Sets a float parameter.

## SetInt

```
func (Animator) SetInt(name string, value int)
```

Sets an int parameter.

## SetTrigger

```
func (Animator) SetTrigger(name string)
```

Sets a trigger for the next fixed step; a transition that uses it, or the end of that step, clears it.

## StateName

```
func (Animator) StateName(index int) string
```

Returns the name of a state index, as StateEntered and StateExited report it.

## Event

```
signal Event(id int, payload float)
```

Runs when a state reaches an event of its clip; during a blend the state's event policy decides which side reports.

## StateEntered

```
signal StateEntered(state int)
```

Runs when the animator enters a state, at the start of the transition.

## StateExited

```
signal StateExited(state int)
```

Runs when a state stops playing, at the end of the transition.
