Skip to main content
F
24d ago

Issue regarding restarting animation based on Trigger in Unity.

Hello,

I am trying to create a countdown animation and play it in Unity using a trigger.

I find the correct Trigger using:
restartTrigger = m_stateMachine.GetTrigger("onRestart");

And I'm able to start playing it using:
restartTrigger.Fire();

However if I want to fire the trigger again later on it doesn't start the animation again.
In the Rive Animation Editor I made sure the Animation State switches to an empty state based on the duration of the animation in milliseconds. And this all seems to work perfectly in the preview (also restarting the animation multiple times).

So my question is:
How can I make the trigger play the animation again in Unity?

Kind regards,

Gerard

Fittar

9 replies
F
24d ago

Do you mind sharing the .rev file so I can take a closer look?

23d ago

The Rive file and the code snippet you posted looks right to me. Which version of the runtime are you using? If it's not the latest, can you try upgrading. If that doesn't work, can you share a working example so I can try it in Unity?

22d ago

I'm also not able to reproduce this on my end with your file in Unity. It's restarting as expected for me.

If you could share a Unity project that reproduces this, that would be helpful.

F
22d ago

Hi I can not share my entire Unity Project as it's pretty large.

I'm using v.0.2.1 Runtime as a unity package.

I'm using the code below for finding the Trigger and Activating it:

if (restartTrigger != null)

{

Debug.Log("Fire Trigger Rive");

restartTrigger.Fire();

}

else

{

Debug.Log("No Restart Trigger Rive");

restartTrigger = m_stateMachine.GetTrigger("onRestart");

}

F
22d ago

And as I said in my previous post, the first time the trigger works perfectly, the second time it doesn't start.

F
22d ago

Couldd you Adam, show me your code otherwise?

22d ago

I'm using the default RiveScreen code from the examples, and caching the trigger like you're doing. Is it possible that you're re-triggering before the spinner animation is complete? It doesn't look like your animation is set up for that.

You don't have to send your main project. It's actually better that you send a new project solely to reproduce the issue in an isolated environment.

F
17d ago

Hi I tried it in an empty project and everything seemed to work fine. Then I tried it in an empty scene in my working-project and everything seemed fine. I even used the same code as in my working-scene. However in my working scene I set the canvas with the animation to false once it's done. I think the issue is being caused by that, maybe it's breaking the RenderTexture or something.