GPU Particles 2D emit only when visible

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rotthin

Hello! I found out that GPU Particles2D emit only when they’re visible. For me this is a problem because when i spawn an explosion particle out of camera’s view and go over to it later, the particle just starts to emit, but it should be over. This doesn’t happen when I use CPU Particles2D. Here’s video

:bust_in_silhouette: Reply From: Xrayez

I think you can workaround this by making sure that you queue_free() those explosion nodes regardless, but you have to know the time it takes for the explosion to fade out:


extends Particles2D

func _ready():
    # Assuming explosion is momentary, not needed for smoke-like effects.
    one_shot = true 
    # Start emitting.
    emitting = true

    # Adjust the time it would take for the explosion to fade out.
    var seconds = lifetime * 2 # Can be different...

    # Create a timer and delete node once particles are finished emitting.
    get_tree().create_timer(seconds).connect("timeout", self, "queue_free")

Unfortunately, there seems to be no built-in signal which allows you to do this for one_shot particles, so that’s the only way I can think of to solve this problem.