← Pixel Dreamer Studio

Particles that play the same way every time

Use Fixed Seed keeps the random numbers. Seed picks which ones.

Each restart() of a GPUParticles3D picks new random numbers, so a burst never comes out the same way twice. Turn on use_fixed_seed and set seed: in our test, the burst then matched pixel for pixel on every restart. Another seed gives another pattern, also the same every time.

Three bursts of small orange squares. The left and middle bursts have exactly the same shape, the right one is different
The script below in Godot 4.7 with the Compatibility renderer, three copies started in the same frame. Left and middle: seed 1234. Right: seed 99. An orthographic camera, so all three are seen from the same direction.

The code

Attach this to a GPUParticles3D for a burst of sparks you can replay with play_again(), the same way every time. The two seed lines are the fix.

extends GPUParticles3D
## A burst of sparks that comes out the same way every time it plays,
## for cutscenes, replays and trailer captures. Call play_again() to replay it.


func _ready() -> void:
	amount = 40
	lifetime = 1.2
	one_shot = true
	explosiveness = 1.0
	use_fixed_seed = true  # the fix: the same random numbers on every restart
	seed = 1234  # another number gives another pattern, also the same every time
	var m := ParticleProcessMaterial.new()
	m.direction = Vector3.UP
	m.spread = 60.0
	m.initial_velocity_min = 2.0
	m.initial_velocity_max = 4.0
	m.gravity = Vector3(0, -6, 0)
	process_material = m
	var mat := StandardMaterial3D.new()
	mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
	mat.billboard_mode = BaseMaterial3D.BILLBOARD_PARTICLES
	mat.albedo_color = Color(1.0, 0.75, 0.3)
	var q := QuadMesh.new()
	q.size = Vector2(0.08, 0.08)
	q.material = mat
	draw_pass_1 = q


func play_again() -> void:
	restart()

What we measured

We let the burst run for 0.4 seconds with preprocess, froze it with speed_scale at 0, and compared two pictures, every second pixel. Three runs gave the same result for the fixed seed. About 300 of those points were lit by sparks.

Copies look like copies

Two emitters with the same seed make the same shape, as in the picture. If several of the same effect play at once, give each one its own seed, or leave Use Fixed Seed off for them.

What to change

Bursts from a pool of emitters: hit sparks from an emitter pool. One burst for an explosion: explosion particles in one burst.

Tested in Godot 4.7 with the Compatibility renderer.

More how-tos: Play, stop and remove effects