Printable version

This version is formatted for printing or saving as a PDF.

Endless fireworks

Fireworks made in Flock XR.
Level 2
30 mins

Goal 🎯

Create endless fireworks using random particle effects in a night sky.

Add a sphere 10 times

  • From Events, add the start block to the code area.
  • From Control, add the ‘repeat 10 times’ block inside the start.
  • From Scene, choose Objects and add the ‘add sphere’ block inside the ‘repeat’ block.
  • Tip: Keep the value set to 10 to keep the memory use of your project low.
A sphere is in the centre of the world.

Add random x, y, z values for each sphere

  • From Math, add the ‘random integer from to’ block on top of each x, y and z value in the ‘add sphere’ block.
  • For x set it to -20 and 20. x is across (left to right).
  • For y set it to 5 and 20. y is up and down like a yo yo.
  • For z set it to 1 and 30. z is zooming in and out.
  • Press Play ▶️ to test. 10 spheres will appear in random locations. Each time you press play they will be in different locations.
  • Debug: Check your values with the ones above or in the screenshot. Look up to see all of them.
10 spheres are in the sky.

Set the alpha of the sphere to 0

  • From Materials, drag the ‘set alpha of’ block under the ‘add sphere’ block.
  • Set the value to 0.
  • Press Play ▶️ to test. The spheres should be invisible.
  • Debug: If you can see the spheres, check alpha is set to 0 and check that the block uses the same name as your sphere.

Add particle effects with random colours

  • From Scene, choose Effects and drag the ‘add particle effect’ block under the ‘set alpha of’ block.
  • Change the ‘shape’ to a star.
  • From Materials, add the ‘random color’ block onto the white and blue color blocks.
  • Press Play ▶️ to test. Particle effects will flow upwards in random colours.
Particle effects all go upwards in the sky.

Randomise the particle effect forces

  • From Math, drag the ‘random integer from to’ block onto each x, y and z force value on the ‘add particle effect’ block.
  • Set x, y and z to -5 and 5.
  • From Control add a ‘wait 1 seconds’ block under the ‘add particle effect’ block.
  • Press Play ▶️ to test. Look around the sky to see beautiful fireworks.
Fireworks appear in random directions.

Take it further

  • Experiment with different wait times.
  • Experiment with different spawn locations for the spheres.
  • Experiment with different force directions for the particle effects.

This project is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Flock XR® and the Flock XR purple bird are trademarks registered to Flip Computing Ltd.