Improved bullet spacing code now works with all number of bullets! Thank

you @jennie!
This commit is contained in:
Henry 2026-04-05 12:21:30 +01:00
parent 0ccdc03bf8
commit 8d89271074

View file

@ -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