I've been looking into the Source Engine lately. More specifically, the strafing/bunnyhopping sort of movement they have.
Here is the actual movement code for the source engine. My question points towards line 1779 and 1784. Here, wishspeed
is given a value of wishdir's
magnitude. Although when a vector (wishdir
) is a normalized vector, wouldn't the magnitude be normalized too? (So it would be a magnitude of 1)
To my understanding that's what happens when something is normalized. If this is true, why is there an if statement of line 1784 with if ( wishspeed != 0 && **(wishspeed > mv->m_flMaxSpeed)**)
, if wishspeed is 1? Looking further into the code, there's more hinting towards wishspeed not being either 0 or 1, but a higher value.
Could someone explain to me how this is possible? How can wishspeed be over 1 when it should've been normalized?
Thanks!
From developer.valvesoftware.com on float VectorNormalize(vec)
:
Divides the vector by its length, normalising it. Modifies the Vector and returns the old length.
wishspeed
takes the length the wishdir
had before it was normalized.