Modified weapon scripts and resources with a simplified spread angle

variable.
This commit is contained in:
Henry Faber 2026-06-25 02:06:28 +01:00
parent 4f90c82b8f
commit 4f3839448b
7 changed files with 75 additions and 3 deletions

View file

@ -34,9 +34,15 @@ func shoot():
# Final position combines symmetrical horizontal spread with symmetrical vertical spacing
bullet.position = player.position + Vector2(bullet_horizontal_offset, weapon_data.origin + (vertical_offset + weapon_data.origin - total_projectiles))
# Calculate angle for this bullet (only when projectiles >= 3)
var bullet_angle: float = 0.0
if total_projectiles >= 3:
bullet_angle = (index_from_center / center_index) * (weapon_data.spread_angle / 2.0)
# Set timing properties on the bullet
bullet.time_offset = time_offset
bullet.fire_time = current_time + time_offset
bullet.angle = bullet_angle
# Set the bullet data
bullet.set_weapon_data(weapon_data.bullet_scene, weapon_data)

View file

@ -15,6 +15,8 @@ extends Resource
@export_category("Spread")
# Horizontal distance between projectiles
@export var horizontal_offset: float = 6.5
# Total spread angle in degrees (only applied when projectiles >= 3)
@export var spread_angle: float = 0.0
# Time delay per projectile index
@export var stagger_offset: float = 0.25