Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Making the animation play slower

Discussion in 'Animation' started by Larpushka, Sep 4, 2015.

  1. Larpushka

    Larpushka

    Joined:
    Jan 6, 2015
    Posts:
    214
    Hi guys, any way I can make the animation play slower?

    Most of the threads I read do it via scripting and they're from 2011, so I'm worried the information there is outdated and there are much more elegant ways to accomplish things, like via the Animator Controller.... etc

    How can I slow down a certain animation?
     
  2. prismix.be

    prismix.be

    Joined:
    Aug 25, 2015
    Posts:
    3
    Do you want it to have a fixed speed?
     
  3. Larpushka

    Larpushka

    Joined:
    Jan 6, 2015
    Posts:
    214
    I just want it to play slow by some sort of scalar value. Like, half the speed, quarter the speed...etc. I prefer to do it in Unity and not in the 3D program where the animation was made.
     
  4. prismix.be

    prismix.be

    Joined:
    Aug 25, 2015
    Posts:
    3
    i'm all new to this myself started coding a week ago but I managed to do this 2 days back.
    I also found these codes from ages ago that are not working anymore. this is what I did to scale my shoot arrow animation to the speed of my arrows per second float variable.

    You might not need to do al the steps.

    In The parameters window add a float var
    In the animator window add a parameter multiplier to your Animation And select the float var you just created.

    In code we can change the value of this var and whenever we change it your animation wil change so make sure the animation is 1sec long to make the calculations easy.

    do this

    Code (CSharp):
    1. public float bowSpeed = 1f; // this is the arrows a second.
    2.     private float animspeed = 1.0f; //this is the speed of the Animation
    3.  
    4. float speed = animspeed/bowSpeed; // simpel calculation to let them match. If I would set bowspeed to 0.5 it wil shoot 2 arrows a second but I I would take the same var for my anim speed it wil play 2 times as slow instead of faster.
    5.  
    6. ClickToMove.anim.SetFloat("BowSpeedAnim", speed); // assigning the var to the parameter.
    7.  
    8.  
    Hope this helps you out
     
    jmoocow2003 likes this.
  5. HarryCodder

    HarryCodder

    Joined:
    Feb 20, 2015
    Posts:
    82
    If you want the playback rate to be constant, just change the speed value on the animation state in your animator.
    The field is just below the motion field where you define what clip to play.

    If not, you could control your animator.speed value via a curve on the animation with some scripting.