From 8d89271074b65bbd2758db19d6fa57cb4fa70fb3 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 5 Apr 2026 12:21:30 +0100 Subject: [PATCH] Improved bullet spacing code now works with all number of bullets! Thank you @jennie! --- scripts/player.gd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/player.gd b/scripts/player.gd index 858b4d5..8a0d763 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -87,7 +87,7 @@ func _on_weapon_cooldown_timeout() -> void: func shoot(): - var projectiles: int = 3 + var projectiles: int = 4 const PROJECTILE_SPACING: float = 10 const MUZZLE_HEIGHT: int = -23 for b in projectiles: @@ -95,7 +95,7 @@ func shoot(): # Instantiate the bullets var bullet = weapon_current.instantiate() get_tree().root.add_child(bullet) - bullet.position = position + Vector2((b * PROJECTILE_SPACING) - (projectiles * projectiles), MUZZLE_HEIGHT) + bullet.position = position + Vector2((b - (projectiles - 1) / 2.0) * PROJECTILE_SPACING, MUZZLE_HEIGHT) # Get weapon speed and spacing for equidistant calculations weapon_rate = bullet.shot_data.rate