0 votes

Hello, I am trying to make the red circle move automatically, to either side .... and that when it collides with the Player's Area2D, it chooses another direction, why should it collide with this ....... idea would be that he run away and that if he approaches him ... look for another direction to get away

Here is the image of the project so that they understand me:https://imgur.com/a/Rq8xg5L

in Engine by (91 points)

Well, it is difficult to understand, first, it looks like the link to your image is chashed and I had to type it. Second, I usually use vector maths to solve enemies behavior, so, you can first add a script to your enemy to make it more organized. That way you can get the player position and set it as a target, so your enemy will go towards player, when enemy hits player's area2D you can use a flag and change the state of the enemy behavior and go away. It can be confusing but let me know if you would like to get this solution and I can explain it better.

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.