0 votes

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 moveandslide 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.

in Engine by (105 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.