using Godot; public partial class ProjectileBase : Area2D { [Export] public float Speed { get; set; } [Export] public float Lifetime { get; set; } protected CharacterBase? Character; protected float Age { get; private set; } = 0f; public override void _Ready() { if (Character is null) { QueueFree(); } } public override void _Process(double delta) { Age += (float)delta; if (Age >= Lifetime) { QueueFree(); } } void OnBodyEntered(Node body) { if (body == Character) { // Ignore self return; } QueueFree(); } public void Spawn(CharacterBase character) { Character = character; Position = character.GlobalPosition; Rotation = character.FacingRotation; TopLevel = false; } }