+1 vote

I am making a match statement that compares a vector's x and y values, however, it only works for my x-axis.

``````print(distance_to)
print(vector2_to_string_match(distance_to))
var y_axis = stepify(distance_to.y, 0.1)
var x_axis = stepify(distance_to.x, 0.1)
print(str("y axis = ", y_axis, ", x axis = ", x_axis, "\ny_axis == -0.7 which is ", y_axis == -0.7,
"\nx_axis == -0.8 which is ", x_axis == -0.8))
``````

the results give me

(-0.754222, -0.656619)
y axis = -0.7, x axis = -0.8
yaxis == -0.7 which is False
x
axis == -0.8 which is True

I recreated it in a new godot project and it's still working like this.

``````var vector = Vector2(-0.751234, -0.6545)
var y_axis = stepify(vector.y, 0.1)
var x_axis = stepify(vector.x, 0.1)

print(x_axis == -0.8) # returns True
print(y_axis == -0.7)# returns False
``````
Godot version 3.2.1
in Engine
edited

should the x_axis not be returning .6?

na if its 0.5 it rounds up.
so it's its 0.65 it would round the 5 up to be 0.7.
I believe that's how it works at least.

``````prints(x_axis == -0.8, y_axis, is_equal_approx(y_axis, -0.7))
`is_equal_approx()` fixes the issue