25 lines
578 B
GDScript
25 lines
578 B
GDScript
extends Area2D
|
|
@onready var animated = $AnimatedSprite2D
|
|
var target : Node2D = null
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
animated.play("ROLL")
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta: float) -> void:
|
|
if target:
|
|
if target.has_method("take_damage"):
|
|
target.take_damage(1)
|
|
|
|
|
|
func _on_body_entered(body: Node2D) -> void:
|
|
if body.is_in_group("Player"):
|
|
target = body
|
|
|
|
|
|
func _on_body_exited(body: Node2D) -> void:
|
|
if body.is_in_group("Player"):
|
|
target = null
|
|
|