How do I make enemies track player characters

I need it for my dungeon crawler and I need players to take damage and have enemy
also need a enemy to track players

Well this how i move the bats in my game, note the Bat is an Sprite with variables as part of the group EnemiesFollowGroup
This is the bat

This is how to move

Just check the distance between the bat and the player then move to and if the distance is greater that you want then move it to the origin, you need to store the origX, origY when you first create the bat enemy. so this way the enemy is going to follow the player when is near and go back when is far away.

1 Like