One Makes Many - Cloning

Objective

After completing this lesson, you will be able to scale your programs by using clones, objects with similar behaviour that run in parallel.

Content

Video summary:

The video explains how to use clones in Snap to generate many agents from a single sprite. It demonstrates creating a rotating, color-changing parent that emits clones; each clone runs its own "when I start as a clone" script, moves outward with an individualized speed that decays over time, and self-deletes when too slow—producing a dynamic flower-like pattern while keeping clone counts under control.

Key points:

  • Clones share a parent’s scripts but can behave differently due to randomness and external inputs.
  • Use "create a clone of myself" and the "when I start as a clone" hat to spawn and control clone behavior.
  • Script variables provide per-script state (e.g., speed) so each clone updates independently in its "when I start as a clone" script.
  • Decay each clone’s speed (e.g., set speed to speed * 0.99) and use "delete this clone" when below a threshold to remove old clones and shape the effect.