← Pixel Dreamer Studio

Make a firework rocket burst at the top of its arc at any launch speed

Burst on the physics frame the rocket stops going up, instead of after a fixed time.

Most firework rockets use one fuse time, but how long a rocket rises depends on how fast it was launched. In our Godot 4.7 test with gravity 9.8 at 60 fps, a 1.5 second fuse was right only for 15 m/s. At 10 m/s the rocket burst on the way down, at 3.85 m instead of its 5.1 m top. At 25 m/s it burst still rising, at 26.35 m of 31.9. Bursting on the frame the upward speed reaches 0 hit the top every time.

The code

Put the script on your rocket scene, add it to the level and call launch(speed). Connect burst to spawn the explosion at the position it gives you.

extends Node3D
## Firework rocket that bursts at the top of its arc at any launch speed:
## it bursts on the physics frame it stops rising, instead of after a fixed fuse.

signal burst(at: Vector3)

@export var gravity := 9.8
var velocity := Vector3.ZERO
var _flying := false


func launch(speed: float, direction := Vector3.UP) -> void:
	velocity = direction.normalized() * speed
	_flying = true


func _physics_process(delta: float) -> void:
	if not _flying:
		return
	velocity.y -= gravity * delta
	position += velocity * delta
	if velocity.y <= 0.0:  # the top of the arc
		_flying = false
		burst.emit(global_position)
		queue_free()

What we measured

Straight up at 10, 15, 20 and 25 m/s, gravity 9.8, 60 fps. Two runs with the same numbers.

Why it happens

A rocket rises for its launch speed divided by gravity: 1.02 s at 10 m/s, 2.55 s at 25 m/s. A fixed fuse can match only one of them. The upward speed itself says when the top is reached, so checking it needs no math and keeps working if you change gravity.

What to change

The burst itself: fireworks without sub emitters. Timing a show to music: fireworks on the beat.

A whole show from cues: Fireworks Show Kit for Godot 4 plays firework cues written in seconds or in beats from a BPM, and can build a whole show with an opening, a climb and a finale.

Tested in Godot 4.7 with the Compatibility renderer.

Ready-made: Fireworks Show Kit for Godot 4 plays firework cues written in seconds or in beats from a BPM, and can build a whole show with an opening, a climb and a finale.

More how-tos for Fireworks Show Kit for Godot 4: A song position that moves on every frame

More how-tos: Fire, smoke and explosions