What’s the easiest way to get a Vector2 value around zero within a threshold?
I’m currently using velocity.is_zero_approx()but I’d prefer it to be within like 2 or 3 in either direction e.g (-2 to 2) for both values of the Vector2.
Is there a way to increase the threshold of is_zero_approx? Or would I have to make a custom function which emulations the same functionality?
Depending on your case you also might use length_squared(). length_squared() is more efficient than length() (length_squared() is x * x + y * y whereas length() is Math.sqrt(x * x + y * y) which is one complex operation more).
var threshold_squared: float = 2.0 * 2.0
if velocity.length_squared() < threshold_squared:
#do something