How to remove a particle2d

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By alexholly
:warning: Old Version Published before Godot 3 was released.

I can’t see any signals on Particle2D. How do I know when the animation is done to free the Particle2D?

:bust_in_silhouette: Reply From: dc1a0
	if not is_emitting():
		queue_free()

That’s how I do it with my explosions

Hmm I am also using is_ emitting it looks like this removes the Particle before the animation is completely done.

alexholly | 2016-03-06 13:10

I haven’t noticed that, You are using queue_free() instead of free() correct?

dc1a0 | 2016-03-06 16:45

alexholly, I also experienced this when explosiveness was set to 0. Then there is some small time lag before the particles start emitting and node was freed before the action. Set it to 0.001 solved this problem.

lukas | 2016-03-06 17:14

dc1a0, I was using free() and now tried queue_free() still the same…

lukas,I can only set explosiveness to 0.01 now the animation looks different and disappears while the animation is still running.

I think a signal is missing, using is_emitting() is also not good for the performance.

alexholly | 2016-03-06 18:27

alexholly, well, if your running it that long, you could time how long it runs and with that info, you could either have it start a timer, (or just use a counter as I would do,) to give it the time you need befroe freeing.

edit: for example, say your particles traveled for .5 seconds:

var lifetime = .5
var time = 0
var start = false
func _process(delta):
     if not is__emitting():
          start = true
     if start:
          time += delta
     if time >= lifetime:
          queue_free()

give or take - done off the top of my head.
Also had to give “is_emitting” an extra “_” because it wanted to italicize for some reason.

dc1a0 | 2016-03-06 20:06

Yes, something like this would work but looks also like a workaround.
I accept this as a answer but also open an issue I think godot should support this.
thanks.

alexholly | 2016-03-06 20:22