Question by
IHateGlamour · Jan 09, 2016 at 12:09 PM ·
velocityvectormagnitude
Vector Normalize() not afecting the vector ?
I am new to Unity, so sorry if it's a stupid question, I tried to limit the velocity of a rigidbody2D vector, and I got a strange bug. As I found out, Normalize() doesn't change the vector magnitude to 1:
if (rb2d.velocity.magnitude > maxSpeed)
{
rb2d.velocity.Normalize();
Debug.Log(rb2d.velocity.magnitude);
...
}
So as I understand the debug should output 1 each time right? But it was not the case, could someone explain why ?
Comment
Answer by Trigary · Jan 29, 2016 at 07:44 PM
Maybe "rb2d.velocity = rb2d.velocity.Normalize();" works, have you tried it?
Your answer
![](https://koobas.hobune.stream/wayback/20220612055536im_/https://answers.unity.com/themes/thub/images/avi.jpg)