My enemy only attack one time, and I need to enter again to they attack the player.
how do I make they keep attacking while the player stay in the area?

Here is my enemy script:

You could use an area to detect if player is in range, and if it is, use a timer to have the enemy constantly attack if this is the case.

Or, on animation finished, you could have the enemy check if the player is still in range.

Another thing to try is check if the attack animation loops.

  • ueih replied to this.

    You probably want to look into state machines (or finite state machines). That way your enemy can have different states, like "walking" "attacking" "escaping", etc. As a simple solution, you can put a method call at the end of the AnimationPlayer "Attack" animation, that switches it to the "Walk" animation, but that won't be very flexible once you have more than 2 or 3 states.

    • ueih replied to this.