From 276b7664bd4a475a3ca93a682c16b49c504c58f7 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Mon, 6 May 2024 16:30:46 +0200 Subject: update --- Scenes/Entities/Enemies/Projectile.gd | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Scenes/Entities/Enemies/Projectile.gd (limited to 'Scenes/Entities/Enemies/Projectile.gd') diff --git a/Scenes/Entities/Enemies/Projectile.gd b/Scenes/Entities/Enemies/Projectile.gd new file mode 100644 index 0000000..af283b4 --- /dev/null +++ b/Scenes/Entities/Enemies/Projectile.gd @@ -0,0 +1,28 @@ +extends CharacterBody2D + + +signal hit + +@export var target: Vector2 +var direction: Vector2 + +@export var speed: int = 50 + + +func _ready(): + velocity = position.direction_to(target) * speed + + +func _physics_process(delta): + $AnimatedSprite2D.play("default") + move_and_slide() + + +func _on_area_2d_body_entered(body): + if body is Player: + hit.emit() + queue_free() + + +func _on_visible_on_screen_notifier_2d_screen_exited(): + queue_free() -- cgit v1.2.3