I am trying to remove SOME (but not all) children from an Aread2D node. I have done this by making an onready var list of $children I would like to delete and iterating through each object with
queue_free (Shown below).
This usually works. Occasionally, however, (like 10% of the time) when I run the
fade_trail function I get the aforementioned error. This is unaffected if I onready var each child separately and don't use a list.
Any ideas on what is causing this? Is there a simple solution I am missing? If you feel extra helpful, read under the code block.
onready var children = [$Sprite, $CollisionShape2D, $WobbleSound]
onready var trail = $CPUParticles2D
onready var fade_out = $Tween
for child in children:
trail.emitting = false
fade_out.interpolate_property(self, "modulate", Color(1,1,1,1), Color(1,1,1,0), .9,
explode.global_position = self.global_position
I am doing this so that the particles following a projectile don't delete immediately when the projectile hits an enemy, but instead fade away before removing the entire node. If there is an easier way to do this, lmk!