According to vector2.h, comparing vectors works like this:
bool operator<(const Vector2 &p_vec2) const { return Math::is_equal_approx(x, p_vec2.x) ? (y < p_vec2.y) : (x < p_vec2.x); }
bool operator>(const Vector2 &p_vec2) const { return Math::is_equal_approx(x, p_vec2.x) ? (y > p_vec2.y) : (x > p_vec2.x); }
That means the y-components of vectors are completely ignored during comparison, unless the x-components are approximately equal to each other. Which is really unlikely, given that you compare your characters velocity (a potentially very big value!) to a value of just 1. So your first and third condition are basically the same!
Of course you could compare the x- and y-components individually to arrive at your desired result. But that will become messy real quick. So here's my solution:
# get the velocity-vectors angle in degrees
var exact_angle = rad2deg(velocity.angle())
# round the angle to the next closest multiple of 45
var rounded_angle = int(round(exact_angle/45)*45)
match rounded_angle:
0:
print("Right")
-45:
print("Up Right")
-90:
print("Up")
-135:
print("Up Left")
180, -180:
print("Left")
135:
print("Down Left")
90:
print("Down")
45:
print("Down Right")