diff options
| author | alex <[email protected]> | 2026-11-23 12:00:20 +0100 |
|---|---|---|
| committer | alex <[email protected]> | 2026-11-23 12:00:20 +0100 |
| commit | 7f4bd1856869d7ae10fa8f07708fbd75c5bb7b1e (patch) | |
| tree | e1fa2d87a79bc8bae87da9e62b19521fe27643e5 /Bullet.cs | |
| parent | 45326f4f10ba2af92ff5d35f0f63e1dc35a4f8eb (diff) | |
| download | godot-testing-7f4bd1856869d7ae10fa8f07708fbd75c5bb7b1e.tar.xz godot-testing-7f4bd1856869d7ae10fa8f07708fbd75c5bb7b1e.zip | |
pesitems
Diffstat (limited to 'Bullet.cs')
| -rw-r--r-- | Bullet.cs | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -6,6 +6,7 @@ public partial class Bullet : Area2D [Export] public float Speed { get; set; } = 600.0f; [Export] public float Damage { get; set; } = 10.0f; public bool PierceEntity { get; set; } = false; + public int EntityPierceCount { get; set; } = 0; public bool PierceTerrain { get; set; } = false; public bool ricochet { get; set; } = true; public int BounceLimit { get; set; } = 5; @@ -62,11 +63,19 @@ public partial class Bullet : Area2D if (collider is IDamageable target) { target.TakeDamage(Damage); - if (!PierceEntity) + + bool canPierceEntity = PierceEntity || EntityPierceCount > 0; + if (!canPierceEntity) { QueueFree(); return; } + + if (!PierceEntity && EntityPierceCount > 0) + { + EntityPierceCount--; + } + GlobalPosition = hitPos + Direction * 0.1f; } else |
