Skip to main content
Interact with the Rive State Machine in Unity. For more information on Rive State Machines see the respective runtime and editor documentation.

State Machines

(Runtime) Rive’s state machines provide a way to combine a set of animations and manage the transition between them through a series of inputs that can be programmatically controlled.

State Machines

(Editor) State Machines are a visual way to connect animations together and define the logic that drives the transitions.

Overview

A StateMachine advances (plays) animations in an Artboard.
A Rive Widget automatically loads and advances the state machine from your artboard configuration settings. Here’s how you can access the loaded state machine in your scripts:
[SerializeField] private RiveWidget m_riveWidget;

...

void OnEnable()
{
    m_riveWidget.OnWidgetStatusChanged += OnWidgetStatusChanged;
}

private void OnWidgetStatusChanged()
{
    // Wait for the Rive Widget to load before accessing the state machine.
    if (m_riveWidget.Status == WidgetStatus.Loaded)
    {
        StateMachine m_stateMachine = m_riveWidget.StateMachine;
    }
}


void OnDisable()
{
    m_riveWidget.OnWidgetStatusChanged -= OnWidgetStatusChanged;
}