How to make spawner queue_free without removing what it spawned

im making a spawner and i added a timer for it to delete itself but the only issue is it deletes the spawned thing here is the script
extends Node2D
@export var magma: PackedScene
@export var levle: PackedScene

func _ready() → void:
$Timer2.start()
$Timer.start()

func _on_timer_2_timeout() → void:
var mag = magma.instantiate()
get_parent().add_child(mag)

func _on_timer_timeout() → void:
queue_free()

Hi,

Where is the code that makes the spawner delete itself? Such an issue may be related to the destruction of the node that’s the parent of both the spawner and the spawned objects.

1 Like

sry i passed the function lol i fixed it in the post

Okay, seems like my guess was wrong.
Have you checked your scene tree at runtime to make sure the spawned nodes are not children of the spawner (could happen if you have some other code affecting that somewhere)?
Also, are there any codes destroying the spawned nodes?

after looking IT NOT EVEN SPAWNING :weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face::weary_face:

You’re probably missing the signals connection:

$Timer.timeout.connect(_on_timer_timeout)
$Timer2.timeout.connect(_on_timer_2_timeout)

oh well then i just notised that thanks im gonna cry myself to sleep now… god bless

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.