# Controllers

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

    controller version=1 {
      entry="Idle"
      param "Speed" kind=float {}
      param "Grounded" kind=bool default=true {}
      param "Attack" kind=trigger {}
      state "Idle" clip=asset("…idle") {}
      state "Run" clip=asset("…run") speed=1.2 {}
      state "Hit" clip=asset("…hit") loop=once events=both {}
      transition "Idle" to="Run" duration=0.1 {
        cond "Speed" op=gt value=0.1 {}
      }
      transition "Run" to="Idle" duration=0.1 {
        cond "Speed" op=le value=0.1 {}
      }
      transition "any" to="Hit" interrupt=true {
        cond "Attack" {}
      }
      transition "Hit" to="Idle" exitTime=1 duration=0.05 {}
    }

| Part | Meaning |
|---|---|
| `param` | `kind` is `bool`, `int`, `float` or `trigger`; `default` for the first three |
| `state` | `clip`, `speed`, `loop` (`once`, `loop`, `pingPong`; default from the clip), `events` (see below) |
| `entry` | the state the animator starts in |
| `transition "From" to="To"` | `"any"` as the source leaves every state but the target |
| `cond` | `op` is `eq`, `ne`, `gt`, `ge`, `lt` or `le` with a `value`; without `op` a bool or a trigger must be set |
| `duration` | seconds of the blend; 0 switches at once |
| `exitTime` | the transition waits until the state has played this many passes of its clip: 1 is one pass |
| `interrupt` | the transition may cut into a blend that is running |

Every fixed step the animator advances its states, then looks for a transition: first the `any` transitions in their order, then those of the current state. All conditions must hold. During a blend only `interrupt` transitions are considered. Transitions with no duration may follow each other, up to eight in one step; one with a duration ends the step. The importer checks names, operators and loops of instant transitions ([ANC001](/diagnostics.html#ANC001.md), [ANC002](/diagnostics.html#ANC002.md), [ANC003](/diagnostics.html#ANC003.md), [ANC005](/diagnostics.html#ANC005.md)); a state whose clip is missing plays nothing ([ANC004](/diagnostics.html#ANC004.md)).

## Blends

A blend mixes the outgoing and the incoming state by a weight that follows `ease` of the controller, `inOutQuad` by default. Numbers, vectors and colours interpolate, rotations take the short arc, sprites and other steps switch at half weight. A property that only one of the two clips animates blends from the value it had when the transition started. When an `interrupt` transition cuts into a blend, the pose on screen at that moment becomes the outgoing side, so nothing jumps.

## Events during a blend

| `events` of the incoming state | Events that run |
|---|---|
| `dominant` (default) | those of the state whose weight is at least half at the moment of the event |
| `both` | those of both states |
| `incoming` | those of the incoming state only |

An event at the start of the incoming state happens at weight 0, so with `dominant` it belongs to the outgoing state: put the hit of an attack where the attack is already in full view.
