godot 4
Im making a wolf3d clone, and im using a delta counter for fire delay of the fully automatic weapon, but with he chaingun weapon im using a frame_changed signal to fire on the second frame (the weapon has 2 frames in its firing animation each lasting 3 frames in 35fps, the sprite fps and game fps have the exact same frame rate of 35, and the animation doesnt loop), i did this to make it when you one tap the weapon it will fire a burst of two shots kinda like wolfenstein or doom
The problem is that after it fires a couple normal shots while holding down fire, the signal will just stop, then after a couple more shots it will go back to normal, then repeat.
im pretty sure the issue is the signal or has something directly do with the signal, i have another weapon in the game that doesnt use the signal and only uses the counter and it works perfectly as intended
video showcasing issue, its doing the issue that ive eplained before, but it should be firing consistant full auto and not switching fire rate because the frame_changed signal for some reason will do the issue that ive explained before:
code:
extends Node3D
@onready var Weapon_Sprite = $CanvasLayer/Control/WeaponSprite
@onready var Hitscan = $Hitscan.get_children()
#var can_fire = true
var fire_rate = 6
var fire_timer = fire_rate
func _ready():
Weapon_Sprite.play("Idle")
func check_hit():
for ray in Hitscan:
if ray.is_colliding():
if ray.get_collider().is_in_group("Enemy"):
ray.get_collider().take_damage(5)
func _process(delta):
#ask godot forums for help with animaion bullshit
if Input.is_action_pressed("main_fire_weapon"):
Weapon_Sprite.play("Fire")
if fire_timer == fire_rate:
Fire()
if fire_timer > 0:
fire_timer -= 1
if fire_timer == 0:
fire_timer = fire_rate
if not Input.is_action_pressed("main_fire_weapon"):
if fire_timer == fire_rate:
Weapon_Sprite.play("Idle")
elif fire_timer > 0:
fire_timer -= 1
if fire_timer == 0:
fire_timer = fire_rate
Weapon_Sprite.play("Idle")
func Fire():
check_hit()
#$Fire is the sound effect player
$Fire.play()
func _on_weapon_sprite_frame_changed():
if Weapon_Sprite.animation == ("Fire"):
if Weapon_Sprite.frame == 1:
Fire()