> ## Documentation Index
> Fetch the complete documentation index at: https://rive-transitions-2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Layers

> Layers let you build more complex logic and animation with the state machine. 

export const YouTube = ({id, timestamp}) => {
  const videoSrc = timestamp ? `https://www.youtube.com/embed/${id}?start=${timestamp}` : `https://www.youtube.com/embed/${id}`;
  return <iframe width="100%" height="400" src={videoSrc} title="YouTube video player" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerPolicy="strict-origin-when-cross-origin" allowFullScreen />;
};

<YouTube id="7Vb1LosMzwk" />

A state machine layer can play one state at a time. Add multiple layers when you want a state machine to play multiple animations or interactions at once.

For example, one layer might control a character's idle and walk animations, while another layer controls a separate hover or selected state.

## Creating a new layer

To create a layer, click the **+** button in the **Layers** tab.

<img src="https://mintcdn.com/rive-transitions-2/V0qymUioAXT1aguO/images/editor/state-machine/state-machine-layer-create.gif?s=daaf5546b016c61c65eced2a665c1980" alt="Adding a new layer" width="640" height="160" data-path="images/editor/state-machine/state-machine-layer-create.gif" />

## Layer Order

Layer order determines which layer takes priority when multiple layers animate the same property.

Layers farther down the list take priority over layers above them. In most cases, this does not matter. However, if multiple layers control the same object property, the animation in the lower layer takes priority as the layers mix.

<YouTube id="Fc9MutscvAo" />

### Changing layer order

To change layer order, drag layers up or down in the **Layers** tab.

<img src="https://mintcdn.com/rive-transitions-2/V0qymUioAXT1aguO/images/editor/state-machine/state-machine-layer-order.gif?s=e4c6c9a13864c70d9deb70a8ea792df9" alt="Reorder state machine layers" width="640" height="160" data-path="images/editor/state-machine/state-machine-layer-order.gif" />

## Layer Menu

Click the **...** button next to a layer name to open the layer menu.

<img src="https://mintcdn.com/rive-transitions-2/V0qymUioAXT1aguO/images/editor/state-machine/layer-menu.png?fit=max&auto=format&n=V0qymUioAXT1aguO&q=85&s=71af20528ff6abfec29208194de05184" alt="Layer menu" width="2912" height="668" data-path="images/editor/state-machine/layer-menu.png" />

| Option        | Description                                                           |
| ------------- | --------------------------------------------------------------------- |
| **Delete**    | Deletes the layer.                                                    |
| **Duplicate** | Creates a copy of the layer.                                          |
| **Disable**   | Disables the layer without deleting it.                               |
| **Snapping**  | Enables or disables snapping for states and transitions in the layer. |
