I’m having a bit of an issue with this very simple bit of code. I’ll show it first:
if(rigidbody2D.velocity.x != 0)
{
Debug.Log ("Velocity Direction: " + new Vector2(rigidbody2D.velocity.x,0).normalized.x);
}
As you can see, if my X velocity is higher/lower than 0, then we log the normalized direction of that velocity. Yet when I’m turning back and forth, resulting in a very slow X velocity, or turning on a slope, it will result in some 0 values, despite it only triggering if my .X velocity is not 0… (and this isn’t an issue with the if statement I don’t think, as it doesn’t log anything if I stand still)
Does .normalized just round down the value if it’s super close to 0? And if so, what do you think I could use instead to get around this issue?