using Godot; public partial class Projectile : Node3D { [Export] public double Cooldown { get; protected set; } [Export] protected float _projectileSpeed = 1f; [Export] public AudioStream _soundEffect; [Export] public AudioStream _onHitSfx; [Export] public RigidBody3D _hitBox; [Export] public bool HasRotation = false; public override void _Ready() { Speed = _projectileSpeed; var sfxPlayer = GetTree().Root.GetNode("Main/SFXPlayer"); sfxPlayer.Stream = _soundEffect; sfxPlayer.Play(); } public override void _PhysicsProcess(double delta) { var pathFollow = GetNode("PathFollow3D"); pathFollow.Progress += Speed * (float)delta; if (pathFollow.ProgressRatio > 0.9f) QueueFree(); } public void OnProjectileHit(Node node) { SetProcess(false); if (node.GetParent() is BasicEnemy basicEnemy && basicEnemy.HasMethod(BasicEnemy.MethodName.OnEnemyHit)) basicEnemy.Call(BasicEnemy.MethodName.OnEnemyHit, node); else GD.Print("Hit something other than enemy: " + node.Name); _hitBox.QueueFree(); var sfxPlayer = GetTree().Root.GetNode("Main/SFXPlayer"); if (!sfxPlayer.Playing) sfxPlayer.Play(); } public float Speed { get; private set; } }