Menu
CoddyTech

Recap: Fireworks

Part of the Unity Scripting Basics section of Coddy's Unity journey. Lesson 54 of 67.

challenge icon

Challenge

Medium

Make the Launcher set off fireworks from the Spark prefab:

  • Each press of Space bursts 8 sparks.
  • Every spark appears exactly 2 units from the launcher, each in its own random direction, with no rotation.
  • Each spark is gone 1 second after it appears.

Press Play and press Space a few times, then Check.

Try it yourself

using UnityEngine;

public class Fireworks : MonoBehaviour
{
    public GameObject sparkPrefab;

    void Update()
    {
        // Space: 8 sparks, each 2 units away in a random direction, each gone after 1 second
    }
}

All lessons in Unity Scripting Basics