#Enemy moves despite the code saying its not allowed to

4 messages · Page 1 of 1 (latest)

celest pendant
#

I'm trying to make an enemy that chases the player around when it enters its area2D, but when i start the game it automatically moves diagonally away from the player, even though the code it has doesnt say it can move until the player enters the area, how can i fix this?

granite rover
#

check, that the area you entered is actually the one attached to the player, not another one. That's my guess on what's happening there

versed galleon
#

If you are using a TileMap with collision then it could be that the enemy is detecting that and then moving towards its origin.
If your enemy is reacting to another body other than the player, one way to fix it would be to give your player's CharacterBody2D a unique collision layer and then change the collision mask of the enemy's Area2D to be the same, so it is only checking for when the player enters it.

lunar venture