Bohdan
Bohdan

Reputation: 11

How to make customizable character in Rive

I want to make customizable character in rive to change his outfit during runtime in flutter, and because there is no way to change assets during runtime I added them in rive and joined to my amimated bones. But i cant find the way to change them whem my main "anim" playing. I wish if I could do it with using inputs as an IDs of clothes. workspace

I make a few animations-states which changes opacity and make visible one clothes and transparent others. I can change them with blend state in state machine but can`t play "anim" at the same time. I expect to someany offer me some way to change clothes

Upvotes: 1

Views: 181

Answers (1)

Nagash
Nagash

Reputation: 48

I don't know how to solve the problem, I change colors of the animation in this way, maybe I can help you to achieve it.

final bytes = await rootBundle.load(animationPath);
final RiveFile file = RiveFile.import(bytes);

    _riveArtboard = file.mainArtboard
      ..forEachChild((c) {

          if (c is Shape) {
            if (c.name == 'SKY') {
              c.fills.first.paint.colorFilter = ColorFilter.mode(
                  Customization.variable_6.withOpacity(.9),
                  BlendMode.lighten);
            } 
          }
       
        return true;
      })
      ..addController(
        _controller = SimpleAnimation('Untitled 1'),
      );

Upvotes: 0

Related Questions