Search Unity

Finish Animator in desired length

Discussion in 'Animation' started by inuside21, May 23, 2019.

  1. inuside21

    inuside21

    Joined:
    Jan 23, 2019
    Posts:
    3
    hello everyone,

    May I ask how to adjust/compress/fast forward ALL my 3~4seconds animations (blender) to finish in 2 seconds without cut.

    I cant find any commands in Animator.

    thank you
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    Each state has a Speed field, but you would need to manually calculate the correct speed for each animation to give the desired duration and manually redo everything if you ever want to make any changes.

    You can also link the speed of a state to a float parameter and set it using a script, but there's no clean way of associating the parameter with the clip to use the clip's length in your calculation.

    As with many animation problems, this one is easily solved by my Animancer plugin (link in my signature). It has a Duration property that does exactly what you want, so you would write something like this:

    Code (CSharp):
    1. void PlayIn2Seconds(AnimancerComponent animancer, AnimationClip clip)
    2. {
    3.     var state = animancer.Play(clip);
    4.     state.Duration = 2;
    5. }
    I also just posted an Open Beta for v3.0 a few days ago which has lots of improvements over the version currently on the Asset Store, including lots of new example scenes and much better documentation in general.