Can't access inputs
I have a Rive file with several artboards and each artboard has its State Machine.
For starters, I thought it’s strange it won’t let me import the file with the name of the main artboard’s state machine which is 'State_Machine-wheel'. I need to use a name of a different state machine, for the file to be imported at all.
const { rive, RiveComponent } = useRive({
src: '/games/hi_lo_wheel/hi.riv',
stateMachines: 'State Machine 1',
autoplay: true,
layout: new Layout({
fit: Fit.Cover,
alignment: Alignment.Center,
}),
});
console.log('STATE MACHINES:: ', rive?.stateMachineNames);
console.log('ACTIVE ARTBORAD:: ', rive?.activeArtboard);
const slotsInput = useStateMachineInput(rive, 'State_Machine-wheel', 'slots');
const choiceInput = useStateMachineInput(rive, 'State_Machine-wheel', 'choice');
console.log('slots', slotsInput);
console.log('choiceInput', choiceInput);
console.log('inputs', rive?.stateMachineInputs('State Machine 1'));
console.log('inputs', rive?.stateMachineInputs('State_Machine-wheel'));
useEffect(() => {
if (rive) {
console.log('setting slots', rive.setNumberStateAtPath);
rive?.setNumberStateAtPath("slots", 20, "WHEEL/spin");
}
}, [rive]);
Here’s the result of my logs. The inputs can’t be accessed, I thought maybe because there’s several artboards they should be set like nested inputs but this doesn’t seem to work either.
What am I doing wrong?