Skip to main content
2mo ago

iOS input not triggering correct animation

Hi πŸ‘‹πŸ» I'm using a Rive file in an iOS app in SwiftUI and I can't get the inputs to work correctly. It's a simple animation that should show a player's score - either +5 or +10. The file has an input called Points and I'm setting the numeric value to either 5.0 or 10.0.

I'm using RiveRuntime 6.0.7.

I can send my code, the .riv file and a screenshot from our designer (once I figure out how to add it here πŸ˜‚)

When calling setInput("Points", value: 10.0) the animation for the value of 5.0 plays but I'm expecting the animation for 10.0 to play πŸ€”

Any help would be greatly appreciated! πŸ™πŸ»

4 replies
2mo ago
[deleted]
2mo ago

I should be able to help you with this. You mentioned that it plays the 5.0 animation. Is that the default animation that would play even if it didn't receive an input? Is the input defined in the main artboard or a nested one?

If you could post the relevant code or a link to GitHub, that'd be great. If possible, could you also include the .rev file?

2mo ago

Thanks for the reply πŸ™ŒπŸ» I've posted the code here: https://gist.github.com/naudecruywagen/0da8112c195dc3a98097ca4fd2bd6286

If I set autoPlay to true the 5.0 animation does play immediately.

I've uploaded the .riv file here https://drive.google.com/file/d/1jBg5P5p9OYZat3Z_AMZr9B_kSWBCIg3F/view?usp=sharing (Is the .rev file something else or were you referring to the .riv file?)

(edited) 2mo ago

I see what's going on now. The problem is actually with the state machine setup, rather than the runtime. Here's a great 101 video explaining how state machines work: https://rive.app/community/doc/state-machine/docwH5zPdh93

In your case, the problem is that the Entry node only runs once ever. When it plays the 5 Points animation, it has nowhere else to go.

If you do the same thing, but connect both timelines to the Any State, it'll run any time Points reaches 5 or 10.

Let me know if this works for you.

2mo ago

Thanks, unfortunately it's still not working for me. Here's a screenshot of the new setup and the riv file. It still plays only the 5 animation πŸ€”

points (5).riv
3 KB