How to get rid of already one shot emitted CpuParticles2d

Godot Version

4.4.1

Question

My problem is:

In editor my CpuParticle2D node is already added as child node to scene and configured as one shot. When time comes i set emitting = true but, if user clicks a button too fast i want to destroy already emitted particles without destroying node(queue_free()) itself. I tried setting visible=false but then it pauses itself and continues to draw already previously started particles if set visible=true. I also tried emitting=false which had no effect on one shot particles. So shortly without freeing the node that is added in editor, i want to destroy already emitted particles.

Note: Tried also process_mode = always to make it not pause when visible is off but it didn’t help.

Hi!

What about setting visible = false, and when you then set visible = true, you also call restart()?
I tried quickly with a simple CPUParticles2D node and it works fine.

Here’s my code (just waiting one second, hiding, waiting one more second, showing and restarting):

extends CPUParticles2D


func _ready():
	await get_tree().create_timer(1.0).timeout
	visible = false
	await get_tree().create_timer(1.0).timeout
	visible = true
	restart()

Thanks, visible=true with restart worked.

1 Like