Closed DavidHajum closed 1 week ago
Any news here? I am facing the same problem!
Hi, are you sure that the input
isn't null?
I went ahead and tested with a new sample, I'll attach the code and .rev file below for you to test. This is how you can set an input before the animation is played.
class SettingInputExample extends StatefulWidget {
const SettingInputExample({Key? key}) : super(key: key);
@override
State<SettingInputExample> createState() => _SettingInputExampleState();
}
class _SettingInputExampleState extends State<SettingInputExample> {
Artboard? artboard;
StateMachineController? controller;
@override
void initState() {
loadRive();
super.initState();
}
Future<void> loadRive() async {
RiveFile riveFile = await RiveFile.asset("assets/inputset.riv");
artboard = riveFile.mainArtboard
.instance(); // important to call instance when self loading
controller = StateMachineController.fromArtboard(
artboard!,
'State Machine 1',
);
if (controller != null) {
artboard!.addController(controller!);
SMINumber input = controller!.getNumberInput("Number 1")!;
input.value = 3.0;
}
setState(() {});
}
@override
void dispose() {
controller?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
if (artboard == null) return const SizedBox();
return Scaffold(
appBar: AppBar(
title: const Text('Simple Animation'),
),
body: Center(
child: Rive(
artboard: artboard!,
),
),
);
}
}
If you're still encountering difficulties it might be that you set up your state machine in a way that toggles it back to that input value. You can reach out to our forums for more help: https://rive.app/community/forums/home
Thank you for your response.
Having trouble opening and using your file though. Could you upload it as a .riv or give advice how to work with .rev?
Thanks
See here for more information on .rev: https://rive.app/community/doc/exporting/dockj1y5YeDd
It's a backup of the Rive project, you just need to drag & drop into My Files or another team folder in the Rive Editor
I am new to Rive and trying to start my Animation at a certain Input
My Animation has an input called "ProgressNumber", with 4 available values: 1.0, 2.0, 3.0 and 4.0.
I currently load the animation like this:
` RiveFile riveFile = await RiveFile.asset( 'assets/animations/rive/onboarding_android.riv', );
`
This results in the animation starting at value 0.0 and animation to 1.0 immediately. If I try to start at 2.0, the animation just stays at 0.0
I want to be able to start at any of the values.
Any guidance would be greatly appreciated.