# Set walk animation speed to velocity

How should I set a character’s walking animation speed to their movement speed?

I got the velocity quite easily — `velocity = (transform.position - lastPosition) / Time.deltaTime;`

Should I use `velocity.magnitude? sqrMagnitude? Normalize?` I’m a bit confused on which one is appropriate.

Many thanks

As far I know:

*magnitude = Gives the length from a vector following the formula velMagnitude = sqrt( (x-xo)^2+(y-yo)^2+(z-zo)^2 ), where sqrt is the square root:

*sqrMagnitude is like the formula used in magnitude, but without the squareRoot part. Since squareRoot operation is heavy, this one is good when you just want to compare two vectors and does not need the real length;

*Normalize returns a vector proportional to the original vector, but with length one. This one is good when you want to create a new vector in the same direction of the original but with a fixed length;

So, for me you should use the magnitude one or save the velocities of the 3-axis (x,y,z) it depends what you want to do.