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.
- Fixed 1.5 s fuse: 10 m/s burst at 3.85 m while falling (top 5.10 m). 15 m/s at 11.35 m, still rising (top 11.48). 20 m/s at 18.85 m, rising (top 20.41). 25 m/s at 26.35 m, rising (top 31.89).
- The script: 5.02, 11.35, 20.24 and 31.68 m, after 1.03, 1.53, 2.05 and 2.57 s. That is the highest point of each flight in 60 fps steps, 0.1 to 0.2 m under the textbook top.
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
- Different heights per rocket: randomize the launch speed, not the fuse.
- Angled launches:
launch(speed, direction)still bursts at the top of the curve, because only the upward part of the speed decides.
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
- Make the explosion as big as its damage
- Fire that turns to smoke in a cone
- Bright fire with dark smoke
- Smoke particles leave a hard line on the ground
- Particles drawing in the wrong order
- Explosion effect in one burst
- 3D debris particles not rotating
- Particles all disappear at once
- Muzzle flash with a real light
- Glowing particles in Godot 4
- Glowing particles cast dark shadows
- Particles from the surface of a mesh, at runtime
- Fireworks without sub-emitters
- Effects on the beat that stay on the beat
- Fire or dust over a whole building
- Steam that turns to black smoke when the food burns
- A torch light that flickers the same on every screen