Seeing that you have used Godot, take a look at the VisibilityEnabler node, it has this exact same function and it is really easy to implement (just put it in your enemies and adjust the visibility range!)
Seeing that you have used Godot, take a look at the VisibilityEnabler node, it has this exact same function and it is really easy to implement (just put it in your enemies and adjust the visibility range!)