0 votes

I want the enemy to stay a set distance away from the player, and move away when the player breaches that distance. I'm not sure how to set this up. Any ideas on how to achieve this?

in Engine by (103 points)

1 Answer

0 votes

Set up an Area2D object with a large collision circle around the enemy, which will be the "fleeing distance". Once the player enters this Area, the enemy can switch to a "fleeing" mode, moving away from the player until the Area is free again.

I created a small demo for this:



by (1,742 points)
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.