Rive State Machines
- rive listner’s action > input change
In Rive, you can switch between different State Machines without using JavaScript by utilizing Events and Inputs within the Rive Editor itself. However, note that fully dynamic switching between State Machines at runtime typically requires code (JS/Flutter/etc.).
That said, here are ways to simulate State Machine switching inside Rive Editor without external code:
Method 1: Use a “Master State Machine” to Control Others
If you have multiple State Machines (e.g., Movement
and Combat
), you can create a “Controller” State Machine that toggles between them using Boolean Inputs.
Steps:
- Create a new State Machine (e.g.,
Controller
). - Add Boolean Inputs (e.g.,
isInCombat
). - Use Conditions to enable/disable animations from other State Machines.
Example Flow:
- If
isInCombat = false
→ PlayMovement
animations. - If
isInCombat = true
→ PlayCombat
animations.
Limitation: This doesn’t truly “unload” a State Machine but rather mutes one while activating another.
Method 2: Use a Single State Machine with Sub-States
Instead of multiple State Machines, combine them into one using nested logic.
Steps:
- Create “Mode” Boolean Inputs (e.g.,
isWalkingMode
,isFightingMode
). - Inside a single State Machine:
- Group
Walk
,Idle
,Run
underisWalkingMode = true
. - Group
Attack
,Block
underisFightingMode = true
.
- Group
- Use Transitions to switch modes.
Example:
Entry → [isWalkingMode?] → Walk
[isFightingMode?] → Attack
Method 3: Use Events to Trigger State Changes
Rive supports Events (timeline markers) that can fire when an animation reaches a certain point.
Steps:
- Add an Event in an animation timeline.
- In the State Machine, use the Event to trigger a transition.
Example:
- An
Attack
animation finishes → FiresattackEnd
Event → Returns toIdle
.
Limitation: This only works within one State Machine, not across multiple ones.
Method 4: Export and Manually Switch in Host App (No Code Workaround)
If you don’t want to use JavaScript/Flutter, you can:
- Export multiple .riv files (each with its own State Machine).
- Use a no-code tool (like Webflow, Unity, or Unreal Blueprints) to swap Rive files based on UI interactions.
Example:
- Button A → Loads
character_movement.riv
. - Button B → Loads
character_combat.riv
.
Which Method Should You Use?
Method | Pros | Cons | Best For |
---|---|---|---|
Master State Machine | No code needed | Limited to toggling, not true switching | Simple mode changes |
Single State Machine | Clean logic | Can get complex | Games/UI with modes |
Events | Built into Rive | Only works per-State Machine | Animation sequencing |
Multiple .riv Files | Truly separate logic | Requires external tool | No-code platforms |
Best Solution?
If you absolutely cannot use code, Method 1 (Master State Machine) or Method 4 (Multiple .riv Files) are your best options.
Would you like a step-by-step Rive Editor guide for any of these? 🎨