diff options
| author | alex <[email protected]> | 2026-07-24 23:33:46 +0200 |
|---|---|---|
| committer | alex <[email protected]> | 2026-07-24 23:33:46 +0200 |
| commit | 91fd5d80808fd177f97c4cc7e78b704efb5d6ce3 (patch) | |
| tree | fc0dee06eae293afb5e429fa0956455aee585f01 /Bullet.cs | |
| parent | 6b666c7f25121e61bf1c58ee65cb2cd0f254b887 (diff) | |
| download | godot-testing-91fd5d80808fd177f97c4cc7e78b704efb5d6ce3.tar.xz godot-testing-91fd5d80808fd177f97c4cc7e78b704efb5d6ce3.zip | |
improved stats resource, weapon now uses dmg from player stats
Diffstat (limited to 'Bullet.cs')
| -rw-r--r-- | Bullet.cs | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -1,14 +1,17 @@ using Godot; - +using testing.interfaces; public partial class Bullet : Area2D { [Export] public float Speed { get; set; } = 600.0f; + [Export] public float Damage { get; set; } = 10.0f; public Vector2 Direction { get; set; } = Vector2.Zero; public override void _Ready() { // Subscribe to the built-in BodyEntered event when the bullet is spawned BodyEntered += OnBodyEntered; + + Rotation = Direction.Angle(); } public override void _PhysicsProcess(double delta) @@ -19,7 +22,10 @@ public partial class Bullet : Area2D // This method is triggered automatically when the bullet hits a physics body private void OnBodyEntered(Node2D body) { - // QueueFree safely deletes this node and all its children at the end of the current frame - QueueFree(); + if (body is IDamageable target) + { + // If it does, deal damage! + target.TakeDamage(Damage); + } } } |
