18 lines
466 B
GDScript
18 lines
466 B
GDScript
class_name Projectile
|
|
extends CharacterBody2D
|
|
|
|
# constants
|
|
@export var speed = 10
|
|
@export var damage = 5
|
|
@export var friendly = false
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
pass # Replace with function body.
|
|
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
var target = move_and_collide(velocity * delta).get_collider()
|
|
if target is Flyer && friendly != target.friendly:
|
|
target.deal_damage(damage)
|
|
queue_free()
|