I’ve seen this line `speed = new Vector2(h,v).sqrMagnitude;`

used a couple times for the parameter in mechanim, but I’m not really sure what it’s doing. Could someone explain to me what its doing exactly?

```
void Update ()
{
h = Input.GetAxis ("Horizontal"); //direction
v = Input.GetAxis ("Vertical");
//speed = h * h + v * v;
speed = new Vector2(h,v).sqrMagnitude; // ??
animator.SetFloat ("Speed", speed);
animator.SetFloat ("Direction", h , directionDampTime, Time.deltaTime);
}
```

sqrMagnitude : Returns the squared length of this vector.

other associated Unity Scripting Reference links :

a lot of terms can be found if you use the search function of the Unity Scripting Reference : Unity - Scripting API:

Simply put - it calculates squared magnitude of your input axes.

What problem it solves:

You could potentially write that

```
speed = h;
```

but that would mean that speed would only change with horizontal and will entirely ignore vertical input. So calculating magnitude or squared magnitude from both of them fixes that by incorporating both input axes (squared magnitude is just faster for CPU).