Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | SneakySteve |
I’ve been creating a script to create a “damage zone”, which is just a sprite with a collision circle as a scene. I instantiate it with this code:
damageZone = load("res://Scenes//DamageZone.tscn").instance()
get_parent().add_child(damageZone)
and this works fine, I can see the sprite appear, and walking into the zone sends the right signals, i handle damage and all that. The problem comes when trying to delete the zone with this code:
if damageZone != null and is_instance_valid(damageZone):
print("before delete")
damageZone.queue_free()
print("after delete")
In the console, I can see both before and after delete messages, but the sprite is still there, and walking into it still causes damage. There are no error messages given whatsoever, what might be causing this?
I’ve tried using other methods to delete as well, things like free(), remove_child(), but these don’t work either.
Not an answer, but when / how do the the two snippets you posted above get called?
jgodfrey | 2022-03-30 19:06
probably, you couldnt call the node which you want to delete. Could you please test" damageZone.position.x+=100 " to see if the node moves when called or try to use get_node(“demageZone”)?
horsecar123 | 2022-03-30 19:50