A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Discussion in 'Animation' started by VoodooDetective, May 5, 2021 at 3:05 AM.
How do I make legacy animations play in unscaled time?
Does the Legacy Animation component have a method like Animator.Update which lets you specify the delta time?
This is what I'm able to do currently, but it feels hacky and ?inefficient?
if (animator.isPlaying == false || string.IsNullOrEmpty(currentAnimation)) return;
AnimationState currentState = animator[currentAnimation];
currentState.time += Time.unscaledDeltaTime;
I thought for sure I was missing something. Also, I'm not entirely sure how this works. I assume it respects the frame-rate of the animation, but I'm not 1000000% positive.
Yeah, that looks rather hacky but I can't see a better way to do it.
Why are you using the legacy animation system though? If it's just to avoid Animator Controllers, you might be interested in Animancer (link in my signature) which can be set to use unscaled time without needing any code.
I actually did buy and love Animancer! The problem is I need the values set by the animator to be retained after the animation completes, and I haven't found a way to make that happen with Animator or Animancer.
With Animator, even if I set "don't write defaults," the animator ignores if I set an object inactive on the last frame.
Do you know anyway to make any of the three options work?