Can't seem to get distance check to work

Godot Version



I have an enemy in my game (2d) loosely based on the weeping angels. It has a navigation agent that calculates a path to the player every second, and in theory if the enemy is a certain distance away, it will teleport, but only if it is further than that distance.

everything works except my distance check, what am I doing wrong?

var dist = position.distance_to(player.position)
	if seen == true && dist > 20 :
		var pos = navmeshAgent.get_next_path_position()

this code is placed in the function from the timer node

try global position
var dist = global_position.distance_to(player.global_position)

That didn’t seem to work. I think the issue is with the “>” in the if statement, it doesn’t seem to be doing anything