Problem with .normalized

Hello all!
I am trying to use a normalized vector direction to control the player walking direction, with:

rb.AddForce(direction.normalized*walkSpeed);
Debug.Log(direction.normalized);

However, the normalization sometimes returns something like (-1.0, 0.0, 0.2) or (-1.0, 0.0, 0.1). The y axis has been set to 0 beforehand that and the error appears in both other axis an both directions. I thought this might be just a problem with the conversion to string, but a doesn’t .2 error seem too much? There is also a noticeable change in speed (depending on the direction you are facing the character moves a bit faster) which I am guessing comes from this… Has anyone ever faced this problem?

It’s a problem with the conversion to a string - the 1.0 isn’t actually 1.0, but 0.98 or 0.99.

You should check the actual value:

var normalized = direction.normalized;
Debug.Log(normalized.x + ", " + normalized.y + ", " + normalized.z);

Then you’ll avoid rounding.