summaryrefslogtreecommitdiff
path: root/Scenes/Entities/Enemies/Projectile.gd
blob: 02a1470488aa4350a1e40f5389277bd52acaeee9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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()