Unreal State Machines

State Machines

Interact with the Rive State Machine in Unreal.

For more information on Rive State Machines see the respective runtime and editor documentation.

Overview

To select a state machine, double-click the RiveTextureObject asset and enter a state machine name. Leaving the name blank will use the default state machine.

A Rive file may contain many artboards, and an artboard may contain many state machines.

Setting Inputs

A Rive state machine can have the following input types:

  • a boolean that can be set to true or false.

  • a number that can be set to any value.

  • a trigger that is a boolean set to true for one frame.

The available inputs can be viewed in the Rive Editor when selecting a state machine, for example:

In the example above:effectsVolume is a number, continueAvailable is a boolean, and back is a trigger.

An Input is accessed by its string name from an Artboard (retrieved from a RiveFile).

Boolean Input

To update a boolean value call Set Bool Value on the artboard.

In the example below, we're setting the boolean input, named isOpen, equal to a local variable Is Open.

To read a boolean value call Get Bool Value on the artboard, and get the return value.

Number Input

To update a number value call Set Number Value on the artboard.

In the example below, we're setting the number input, named health, equal to a local variable Health.

To read a number value call Get Number Value on the artboard, and get the return value.

Trigger Input

To fire a trigger, call Fire Trigger on the artboard.

In the example below, we're firing the trigger named openMenu.

Nested Inputs

You can call these functions on nested inputs by using the node equivalents that end in "at Path". See the Nested Artboards documentation for more details on using nested artboards.

Example

Let's take a look at an example. The video below shows a Rive file with a simple state machine containing one number input, named numExpression.

This number input switches out the active playing animation, and the state machine blends between the different animations as they transition.

From a runtime we can set the numExpression through Blueprint to toggle the correct expression for the Robot.

In this example, the number input is set when the corresponding number key is pressed: