Files
2026-07-21 21:53:18 +02:00

28 lines
707 B
C#

using Godot;
namespace GodotHostTest.Game.Projectile;
public partial class Projectile : Node2D
{
[Export] private PackedScene _explosionPackedScene = null!;
[Export] private float _speed = 100;
public override void _PhysicsProcess(double delta)
{
Position += (float)delta * _speed * Vector2.Up.Rotated(Rotation);
}
private void OnArea2DEntered(Area2D _)
{
var explosion = (GpuParticles2D)_explosionPackedScene.Instantiate();
explosion.GlobalPosition = GlobalPosition;
explosion.Emitting = true;
GetTree().CurrentScene.AddChild(explosion);
QueueFree();
}
private void OnScreenExited()
{
QueueFree();
}
}