27 lines
607 B
GDScript
27 lines
607 B
GDScript
extends Area2D
|
|
class_name ProjectileBase
|
|
|
|
@export var size: float
|
|
var speed = 200
|
|
@export var element: String
|
|
var direction: Vector2
|
|
|
|
func _ready() -> void:
|
|
body_entered.connect(_on_body_entered)
|
|
pass # Replace with function body.
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta: float) -> void:
|
|
position += direction * speed * delta
|
|
|
|
func launch(target: Vector2):
|
|
direction = global_position.direction_to(target)
|
|
|
|
func _on_body_entered(body: Node2D) -> void:
|
|
if body.is_in_group("enemies"):
|
|
body.die()
|
|
queue_free()
|
|
func _remove():
|
|
queue_free()
|