# AnimState

Class · category: Animation

Source: https://github.com/playcanvas/engine/blob/970d89f6d3bc6667f4e1f88153abd6e7e82ed52c/src/framework/anim/controller/anim-state.js#L29

Defines a single state that the controller can be in. Each state contains either a single
[AnimNode](https://api.playcanvas.com/engine/classes/AnimNode.md) or an [AnimBlendTree](https://api.playcanvas.com/engine/classes/AnimBlendTree.md) of multiple [AnimNode](https://api.playcanvas.com/engine/classes/AnimNode.md)s, which will be used
to animate the [Entity](https://api.playcanvas.com/engine/classes/Entity.md) while the state is active. An AnimState will stay active and play
as long as there is no [AnimTransition](https://api.playcanvas.com/engine/classes/AnimTransition.md) with its conditions met that has that AnimState
as its source state.

`speed` and `loop` control the playback of the state's tracks. States are defined in
the [AnimStateGraph](https://api.playcanvas.com/engine/classes/AnimStateGraph.md) and entered either by a transition or directly with
[AnimComponentLayer#play](https://api.playcanvas.com/engine/classes/AnimComponentLayer.md#play).

## Constructors

### constructor

```ts
new AnimState(controller: AnimController, name: string, speed?: number, loop?: boolean, blendTree?: any)
```

Create a new AnimState instance.

**Parameters**

- `controller` (`AnimController`): The controller this AnimState is associated with.
- `name` (`string`): The name of the state. Used to find this state when the controller
  transitions between states and links animations.
- `speed` (`number`, optional, default `1`): The speed animations in the state should play at. Individual
  [AnimNode](https://api.playcanvas.com/engine/classes/AnimNode.md)s can override this value.
- `loop` (`boolean`, optional, default `true`): Determines whether animations in this state should loop.
- `blendTree` (`any`, optional): If supplied, the AnimState will recursively build a
  [AnimBlendTree](https://api.playcanvas.com/engine/classes/AnimBlendTree.md) hierarchy, used to store, blend and play multiple animations.
