sunoku/scenes/enemies/grunt/attack.gd

15 lines
330 B
GDScript

extends Area2D
@export var attack_cooldown : float = 1
var attack_timer = 0
func _process(delta):
attack_timer -= delta
var bodies = get_overlapping_bodies()
for body in bodies:
if body is Player and attack_timer < 0:
attack_timer = attack_cooldown
get_parent().damage(body.incoming_damage)
body.inflict_damage()