pirate-survivors/GPE/CannonBall/cannon_ball.gd
2026-01-17 18:36:34 +01:00

27 lines
628 B
GDScript

extends Area2D
@export var speed: float = 200.0
@export var damage: int = 10
var instigator
func _ready():
# Déplace la balle dans la direction de sa rotation
#var velocity = Vector2(speed, 0).rotated(rotation)
connect("body_entered", _on_body_entered)
connect("area_entered", _on_body_entered)
$LifetimeTimer.timeout.connect(_on_lifetime_expired)
func _physics_process(delta: float):
position += Vector2(speed, 0).rotated(rotation) * delta
func _on_body_entered(body):
if body.has_method("take_damage") and instigator != body:
body.take_damage(damage)
queue_free()
func _on_lifetime_expired():
queue_free()