How would i check how far a character body 2d is from another character body 2d?

Godot Version

4

Question

im making a enemy ai and i want the enemy to stop when its a certain distance away from the player, how would i be able to do this?

Use the function distance to:

var distance = player.global_position.distance_to(enemy.global_position)
print(distance)

Ok i will try it, ty

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.