Welcome to the forums @justiniscoding!
I'm not sure if you figured it out or not, but you should be able to check if the object is above or below by checking the angle using something like this (untested and likely will need adjustment):
# continuing from DaveTheCoder's code...
# for easy adjusting, I would recommend printing the angle
# and then detecting the range that is "below" and "above"
# by looking at the values in the console
# print ("Angle: ", angle_degrees)
var is_below = angle_degrees > 45 and angle_degrees < 135
var is_above = angle_degrees > 225 and angle_degrees < 315
if (is_below == true):
print ("Is below!")
if (is_above == true):
print ("Is above!")
You will likely need to adjust the angle ranges used depending on the rotations of your node, the game's perspective, etc, but hopefully the code helps give an idea of how to take the angle and tell whether the enemy is above/below.
You might also be able to do a simple Y coordinate check as well:
# enemy = reference to enemy
# player = reference to player
if (enemy.global_position.y < player,global_position.y):
print ("Enemy is above player!")
elif (enemy.global_position.y > player.global_position.y):
print ("Enemy is below player!")
You may want to look into using ranges for this as well, so if the player is just a pixel above/below the enemy it doesn't think the player is on top or below, but rather beside.