Search Unity

animation script question

Discussion in 'Animation' started by unity992, Mar 16, 2018.

  1. unity992

    unity992

    Joined:
    Jan 24, 2018
    Posts:
    44
    hi i'm following a tutorial on youtube and they use this code to control the animation of the player whether it is idling,walking or running.
    why velocity.magnitude divides by speed?he said velocity magnitude is the current speed why is that the current speed?sorry i suck at maths
    Code (CSharp):
    1. float speedpercent = agent.velocity.magnitude / agent.speed;
     
  2. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    551
    Link to the tutorial would be better since you gave one line without context. So far I can assume that this value then used as a blend factor in the animation blend tree (0.2 would play the walking animation, 1.0 is running, everything in between will blend those 2 clips).