How can I detect if two Vector2 are near each other?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By usurun

This is what I have and I just want to detect if they are near.

if cam.position > targetPos - (Vector2.ONE*4) and cam.position < targetPos + (Vector2.ONE*4) : pass
:bust_in_silhouette: Reply From: kidscancode

You can’t compare vectors with >. You can find the distance between two points with:



if cam.position.distance_to(targetPos) < 4: