diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-05-06 16:30:46 +0200 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-05-06 16:30:46 +0200 |
commit | 276b7664bd4a475a3ca93a682c16b49c504c58f7 (patch) | |
tree | 6b8f8cf0e1a82496c1f539e55e26bc078300b23a /Scenes/Entities/Enemies/Projectile.gd | |
parent | 8c0e8b5bf73caaf2fd6f04fb97b9c13f2970c431 (diff) |
update
Diffstat (limited to 'Scenes/Entities/Enemies/Projectile.gd')
-rw-r--r-- | Scenes/Entities/Enemies/Projectile.gd | 28 |
1 files changed, 28 insertions, 0 deletions
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() |