Enemy doesn't stop when it collides with the player, and moves around in a pattern. Please take a look.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MaximoTG98

I’ve been testing new things inside Godot 3.0.
One of them is an AI for a simple enemy since I don’t want it to try to follow the player always I made an area node to detect if the player steps in. And there is no gravity.

I’m using default Godot icon.png for the player and enemy.

But I’m having trouble with:

  • If I move inside the x-axis everything works well except it keeps pushing me (2-4 px), I thought that the enemy is trying to get inside the player so I made an offset to avoid that. But it didn’t work, keeps pushing.
  • The big one, in the y-axis, if I move just 5 pixels above the enemy or under it tries to follow the player and if I stop moving the enemy keeps moving between a range(e.g. starting from 0 to 20 and then going to -20 but then comes back to 20 over and over again).

I also saw my enemy moving around the player without stopping.

I’ve thought for the first issue that the move_and_slide residue when it tries to keep pushing.
And for the second issue, I can’t think of anything…

I’m following this tutorial btw but using parts of the code that I had: https://www.youtube.com/watch?v=WXC8eBCEbho

Note: I’m not posting my code because most of the variables and functions are in Spanish, it will be chaos to translate everything. If someone needs more information or something ask.