Original Post
Have a strange problem... I''m using a simple vector for velocity in a test app I''m writing. I want to limit the velocity of the object to 5 (just an arbitrary number). This is what I''m doing:
if(vector.Length() > 5)
{
vector.Normalize();
vector.Scale(5);
}
The functions are known to work fine. Length simply calculates the magnitude of the vector, Normalize I think we all know, and scale simply multiplies each component by the factor. It is limiting the velocity fine, but what I am finding is that as I move it looses velocity on another axis. For example I start moving right and it limits the velocity fine. But then I press up to go up, and it looses the right velocity very quickly. I know that my movement code is working ok because if I take the limiting part out, it works like a charm. What is happening to my velocities? Are they being lost in rounding?
Always remember, you''''re unique. Just like everyone else.