Well, i will try to explain how to do.
Firstly we need to learn that we are approaching the enemy.
I think we can do this with:
const MINIMUM_DISTANCE = 300 # minimum 300 pixel
onready var enemyNode = $EnemyNode # enemy node
onready var myNode = $MyNode # our node
if enemyNode.global_position.x - myNode.global_position.x < MINIMUM_DISTANCE:
i hope this will be helpfull for you.