I understood you are working in 2D. I have only worked in 3D, but it should be almost the same:
var PlayerPos = self.get_global_transform().origin
var PointsArray = [Vector2(0, 0), Vector2(5, 5)]
for Point in PointsArray:
var DistanceToPoint = PlayerPos.distance_to(Point)
if DistanceToPoint > 10:
allowShoot = false
ORIGIN is a property of TRANSFORM, and is a Vector2 in 2D and a Vector3 in 3D. Since you already have a position in Vector2 format, you just need your player position in Vector2.
I don’t know if there’s an engine method to check distances in an array of vectors. But here’s a loop to check each frame if any of the distances within an array exceeds a value:
func _process(delta):
var vector_array = []
var maxdistance = 100.0
for idx in range(0, vector_array.size()-2):
var p0 = vector_array[idx]
var p1 = vector_array[idx+1]
if p0.distance_to(p1) > maxdistance:
allowShoot = false
break
pass
EDIT: previous loop range could crash the game, fixed it.
This worked perfectly thank you!!!
And sorry to the other people commenting for not explaining myself well enough!