# AnimStateGraph

Class · category: Animation

Source: https://github.com/playcanvas/engine/blob/f059dc005842f76e052cdf44d8370c8c7ec475ac/src/framework/anim/state-graph/anim-state-graph.js#L21

An asset resource which represents an anim state graph. It can be loaded into an anim component using the [AnimComponent#loadStateGraph](https://api.playcanvas.com/engine/classes/AnimComponent.md#loadstategraph) method.

The graph is data, not behavior. It lists its `layers`, each with its states, the
transitions between them and their conditions, and the `parameters` those conditions read.
Loading it into a component builds the runtime [AnimState](https://api.playcanvas.com/engine/classes/AnimState.md), [AnimTransition](https://api.playcanvas.com/engine/classes/AnimTransition.md) and
[AnimBlendTree](https://api.playcanvas.com/engine/classes/AnimBlendTree.md) objects, and [AnimComponent#assignAnimation](https://api.playcanvas.com/engine/classes/AnimComponent.md#assignanimation) then attaches an
[AnimTrack](https://api.playcanvas.com/engine/classes/AnimTrack.md) to each state. One graph can drive any number of components.

## Usage
Scripts can retrieve an AnimStateGraph instance from assets of type 'animstategraph'. An AnimStateGraph can then be loaded into an anim component as follows:
```javascript
const animStateGraph = app.assets.get(ASSET_ID).resource;
const entity = new Entity();
entity.addComponent('anim');
entity.anim.loadStateGraph(animStateGraph);
```
