Godot Version
v4.6.1
Question
really specific question. i have a debuff manager component and debuffs. the debuffs are added as children of the debuff manager. however, they do not seem to be queue_free()ing properly?
here is my code for each debuff:
extends Node2D
@export var damage : float
@export var duration : float
@export var slows_player : bool
@onready var stop_timer := $timer
@onready var particle_timer := $timer
func _ready() -> void:
# despawn?? timer
stop_timer.wait_time = duration
particle_timer.wait_time = duration * 0.8
stop_timer.start()
particle_timer.start()
func _on_timer_timeout() -> void:
queue_free()
func _on_particle_timer_timeout() -> void:
$particles.emitting = false
here is my debuff manager code (probably really spaghetti’d because ive just been trying random stuff to fix this)
extends Node2D
@export var health_manager : Node2D
var damage = 0.0
var slow_player : bool = false
func recalculate_debuffs() -> void:
damage = 0.0
slow_player = false
for child in get_children():
if child.is_in_group("Debuff"):
damage += child.damage
if child.slows_player:
slow_player = true
func _on_child_entered_tree(node: Node) -> void:
if node.scene_file_path != "":
for child in get_children():
if child != node and child.scene_file_path == node.scene_file_path:
node.queue_free()
child.stop_timer.stop()
child.stop_timer.wait_time = child.duration
child.stop_timer.start()
return
recalculate_debuffs()
func _on_child_exiting_tree(_node: Node) -> void:
recalculate_debuffs()
func _on_timer_timeout() -> void:
# apply debuff affects
health_manager.health -= damage
i have tried putting a print in the debuff thign where queue_free() happens, and it worked. whenever i print children of the manager in recalculate_debuffs(), the debuff is still there even though the particles stopped a while before that (definitely more time than would be left with the 0.2x difference between particles stopping and the debuff queue_free()ing)
sorry about this being really long. its a really specific problem.. i think? idk ive been trying to fix it for a few hours