- Edited
Hi all,
I'm trying to make a 2D turn based battle game and I'm facing the following problem:
When I work with player (blue rect) and enemy (red rect) with the same dimension (A), I can get their distance using distance_to and it works great. However, if I have an enemy with different dimensions (B or C), distance_to funcion is not working properly, since the pivot point is different for those cases.
I'm using the following code to check the distance:
if player.global_position.distance_to(enemy.global_position) <= Global.MELEE_ATTACK_DISTANCE:
return true
else:
return false
Global.MELEE_ATTACK_DISTANCE = 64 (which means the player dimension)
Is there a better way to do that properly?
Thanks in advance.