Slight update to fire timing to allow for even pairs.

This commit is contained in:
Henry Faber 2026-06-13 15:47:41 +01:00
parent 936bcbc5e3
commit 48a2ba3ddb
3 changed files with 41 additions and 24 deletions

View file

@ -1,20 +1,40 @@
extends Area2D
@onready var bullet: PackedScene = load("res://scenes/weapon_stock.tscn")
@onready var bullet: PackedScene = load("res://scenes/weapon_stock.tscn")
@onready var shot_data: = load("res://resources/player_weapons/weapon_shot_stock.tres")
# Time offset when this bullet was fired (relative to other bullets)
# Time offset when this bullet was fired (relative to other bullets in the same shot)
var time_offset: float = 0.5
#func activate():
# Bullet does its damage/projectile work
# When this bullet should fire (absolute time)
var fire_time: float = 0.0
# Track if this bullet is currently active in the shot
var is_active: bool = false
func _process(delta):
var current_time = Time.get_ticks_msec() / 1000.0
#Calculation position along Y axis
position.y -= shot_data.speed * delta # Original Speed
#position.y -= 330 * delta # non-shot_data testing
# Fire if it's time and bullet isn't already active
if !is_active and current_time >= fire_time:
activate()
func _on_visible_on_screen_notifier_2d_screen_exited() -> void:
queue_free()
# Move the bullet
position.y -= shot_data.speed * delta
func activate():
is_active = true
visible = true
# Emit signal for hit detection
emit_signal("activate")
func _on_visible_on_screen_notifier_2d_screen_exited():
queue_free()
# Set fire_time for the next shot (staggered firing)
var current_time = Time.get_ticks_msec() / 1000.0
fire_time = current_time + shot_data.stagger_offset