KybernetikGames / animancer

Documentation for the Animancer Unity Plugin.
63 stars 8 forks source link

Animancer isn't necessarily evaluated between Coroutine and rendering? #317

Closed kodra-dev closed 8 months ago

kodra-dev commented 9 months ago

From this flow chart, I assume animation evaluation happens between yield new WaitForSeconds and rendering. Therefore, starting playing a new clip (_animancerComponent.Play(clip)) from a Coroutine is safe.

image

However, I found if I start playing a clip from a Coroutine owned by another game object, it sometimes results in rendering unevaluated state from one frame, causing the animation flickers.

If I add:

void LateUpdate() {
   _animancerComponent.Evaluate();
}

The problem is completely gone. Which implies animancer is not always evaluated between Coroutine and rendering? What's the rule of the timing of evaluation? And is there a better solution than calling Evaluate() manually?

KybernetikGames commented 9 months ago

Animancer is updated by Unity during the regular animation update so its should generally follow the diagram.

Is it a newly instantiated character? It could be that Unity isn't updating it on that frame because it was only added to the end of the update list. In that case, calling Evaluate in the coroutine after Play is likely the correct solution.

kodra-dev commented 9 months ago

But if happens with existing game objects too. It happens in a live project... but perhaps I could try to make a reproducible sample project when I have time for it

KybernetikGames commented 9 months ago

I tried a few things but wasn't able to replicate what you've described, so please do send me a minimal reproduction project if you can.