rive-app / rive-flutter

Flutter runtime for Rive
https://rive.app
MIT License
1.16k stars 180 forks source link

Query on Controlling Nested Artboard State Machines from Main Artboard #365

Open blake-lim opened 3 months ago

blake-lim commented 3 months ago

Dear Team,

I hope this message finds you well. I am currently working on a project where I am utilizing Rive within a Flutter application. I have encountered a challenge that I hope you can help me with.

I have a main artboard that contains a nested artboard referred to as 'Hair1'. This nested artboard includes a state machine named 'State Machine 1' with an input titled 'Color Number'. My objective is to change the hair color in the nested artboard 'Hair1' to blue when 'Color Number' is set to 1 at runtime.

My questions are as follows:

  1. Is it possible to directly control the state machine of a nested artboard from the main artboard within the Rive runtime environment?

  2. If direct control is not possible, does Rive allow for 'Expose to Parent Artboard' settings that would enable the main artboard's runtime to control inputs that have been exposed from a nested artboard?

I am looking for a solution that allows me to manipulate the state machine inputs of a nested artboard or its exposed inputs through the main artboard at runtime in a Flutter application.

Any guidance or suggestions you can provide would be greatly appreciated. I am eager to find a solution that maintains the performance and responsiveness of the application while enabling the desired level of control over the nested artboard's elements.

Thank you for your time and assistance. I look forward to your response.

S-Khavin commented 3 months ago

I am also facing the same issue. I have exposed inputs to parent artboard in rive, but when I try to access those input's in my flutter application, the state machines inputs are empty. I still not found any solution for this.

I am using flutter flame.

Future<void> onLoad() async{
    controller = StateMachineController.fromArtboard(
      artboard,
      'State Machine 1',
    );
    artboard.addController(controller!);
    print(controller!.inputs);  // this prints '[]' but there are exposed input's in the artboard
    background = RiveComponent(artboard: artboard);
    add(background);
    return super.onLoad();
  }
naychrist commented 2 months ago

this works for me: https://github.com/rive-app/rive-flutter/issues/341