Queue_free timing help

Godot Version

v4.3 Stable

Hi, if anyone could help me that would be really cool. I’m just really confused why this node seems to create space when it’s queue_free()’d from an attack but if I manually do it or hide it in the editor no extra space is created. I’m rather new to using control nodes and it doesn’t seem to make a lot of sense

explorer_1CnF6Ru6BD

func enemy_take_turn():
	var battle_target: CharacterBase = PartyGlobal.party.pick_random()

	var active_member = turn_queue[current_turn_index]

	var damage = randi_range(1,10) + active_member.current_agility
	
	print("==== Starting Attack ====")
	battle_target.take_damage(active_member.base_damage_type, damage, true)

	print(
		battle_target.character_name,
		" took ",
		damage,
		" ",
		active_member.base_damage_type,
		" Damage from ",
		active_member.character_name
	)

	if battle_target.current_hp <= 0:
		print(battle_target.character_name, " has died")
		
		if battle_target is CharacterBase:
			for child in player_data_container.get_children():
				if child.character_template == battle_target:
					await get_tree().process_frame
					child.queue_free()
					break
		else:
			print("Yeah, Idk Either Chief")
			return
			
		turn_queue.erase(battle_target)
	print(battle_target.character_name, " Current HP:", battle_target.current_hp)
	active_member.take_attack()
	end_turn()

func _on_button_pressed() -> void:
	player_data_container.get_child(3).queue_free()
	print(player_data_container.get_child_count())
	
	end_turn()

Make your PlayerPanel node a PanelContainer instead of Panel type and see if that’ll fix anything.

This is quite odd…

After the removal, even the text box before the cards has been re-scaled correctly


You could try to connect the Player_Data_Container’s sort_children() signal to a method to see if it’s correctly called, tho I don’t know why it would not be…

This is very much a hack, but if it is called and yet the container does not resize itself, you could maybe try to use the signal to update a layout property of the container?

Try using hide() on the node to make it disappear, then use queue_free() on it.

Hey thanks for all the help, I figured out it was the highlighter function when I disabled it everything snapped in place after a death. Is there a safer way to move a control node during runtime or should I just use another visual indicator like a cursor or something?

var actor_to_ui := {} 

func player_turn_highlighter():
if current_turn_index >= turn_queue.size():
    return

var actor = turn_queue[current_turn_index]
await get_tree().process_frame
if actor is CharacterBase and actor_to_ui.has(actor):
	var child = actor_to_ui[actor]
	
	var tween = get_tree().create_tween()
	tween.set_trans(tween.TRANS_ELASTIC)
	var target_pos = child.position + Vector2(0,-10)
	tween.tween_property(child, "position", target_pos, 0.5).from_current()
else:
	print("Not Player Turn, Highlight check")