← Pixel Dreamer Studio

Remove all particles at once

restart() clears the particles that are out. emitting = false right after keeps new ones from starting.

emitting = false stops new particles, but the ones already out live to the end of their lifetime. Call restart(), which removes every particle that is out, and then set emitting = false. In our Godot 4.7 test, an aura with a 2 second lifetime still showed 239 to 249 lit points 0.5 seconds after emitting = false. With the script's clear(), the next frame still showed the old particles and the frame after that was empty.

Left: two purple auras. Right: only the left aura is still there
Godot 4.7 with the Compatibility renderer. Left: 0.1 seconds before we stopped them. Right: 0.3 seconds after. The left aura only had emitting set to false, the right one called clear().

The code

Attach this to a GPUParticles3D and call clear() when the player respawns or teleports. Set emitting = true to start it again.

extends GPUParticles3D
## A looping aura with clear(), which makes every particle vanish at once: for a respawn, a teleport or a level reset.
## emitting = false alone stops new particles but lets the ones already out live out their lifetime.


func _ready() -> void:
	amount = 80
	lifetime = 2.0
	var m := ParticleProcessMaterial.new()
	m.emission_shape = ParticleProcessMaterial.EMISSION_SHAPE_SPHERE
	m.emission_sphere_radius = 0.6
	m.direction = Vector3.UP
	m.spread = 20.0
	m.initial_velocity_min = 0.3
	m.initial_velocity_max = 0.6
	m.gravity = Vector3.ZERO
	process_material = m
	var mat := StandardMaterial3D.new()
	mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
	mat.billboard_mode = BaseMaterial3D.BILLBOARD_PARTICLES
	mat.albedo_color = Color(0.7, 0.5, 1.0)
	var q := QuadMesh.new()
	q.size = Vector2(0.08, 0.08)
	q.material = mat
	draw_pass_1 = q


func clear() -> void:
	restart()  # removes every particle that is out
	emitting = false  # and stops new ones. Set emitting = true to start again.

What we measured

An aura of 80 particles with a 2 second lifetime, running for 2.5 seconds before we stopped it, with about 340 lit points on screen. We counted lit points right after, then 0.5, 1.5 and 2.5 seconds later. Two runs of each.

One frame late

The frame right after clear() still showed the old particles. If they must not be seen at all, for example during a cut to another camera, also set visible = false when you clear, and back to true when you emit again.

What to change

To let them fade out instead: fade out and stop looping particles. An effect that should vanish with its owner: particles and queue_free().

Tested in Godot 4.7 with the Compatibility renderer.

More how-tos: Play, stop and remove effects