Skip to main content
m
2mo ago

How to access nested artboard inputs.

Hello, I've been trying to develop a tic tac toe using Rive. Here's what I have.

https://codesandbox.io/p/sandbox/exciting-frost-v67k7m

Essentially I have a "Tile" artboard that have 2 inputs and one Listener, respectively, Player and Active?. In addition to that I have another artboard called NestedTileGrid which is composed by 9 "Tile" artboards. I want to load the "NestedTileGrid" and from there I would like to be able to access the inputs inside the "Tile"s. I thought I would get access to the inputs by using:

const inputs = r.stateMachineInputs("NestedTileGrid");

but I get an array with 0 length.

Doing some more digging into the docs I've found the following link, but, trying to use those functions - setNumberStateAtPath, setBooleanStateAtPath - within the rive instance I get "setNumberStateAtPath is not a function" on the console.

https://rive.app/community/doc/state-machines/docxeznG7iiK#nested-inputs

I've tried using the following versions and I get the same result.

https://unpkg.com/@rive-app/canvas@1.0.102

https://unpkg.com/@rive-app/canvas@2.9.1

So my question is: How can I access to the inputs within the Tiles inside the NestedTileGrid?

1 reply
T
T
2mo ago

Hello!

I've taken a look at your example code. Setting nested inputs works properly after updating to the latest Rive (version 2.19.4). I changed line 61 to an example of setting a nested input:

r.setNumberStateAtPath("Player", 1, "2:2");


Querying a list of nested inputs is not supported. But you can set and read inputs and fire triggers on nested artboards. All functions supporting nested inputs end with "atPath":

// Returns the input value with the provided name at the given path
retrieveInputAtPath(inputName: string, path: string)
// Sets the input with the provided name at the given path
setNumberStateAtPath(inputName: string, value: number, path: string)
// Sets the input with the provided name at the given path
setBooleanStateAtPath(inputName: string, value: boolean, path: string)
// Fires the trigger with the provided name at the given path
fireStateAtPath(inputName: string, path: string)