Hello, I wanted to make an AI that would attack you if you entered its area. Using the "Area" node as shown by this guy https://youtu.be/OSYehj6oa3U?t=1 but I would need this NPC to be able to attack as well, I can't code almost anything and I can't program my script to attack after entering to his zones.
I would be very happy if any of you could help me.
Here is my movement code, but with it the NPC chases you all over the map.
func _physics_process(delta):
var dir = (player.translation - translation).normalized()
dir.y = 0
if translation.distance_to(player.translation) > attackDist:
move_and_slide(dir * moveSpeed, Vector3.UP)
PS: If full code is needed I will post it.
Thank you.