Skip to content

ParticleEmitter

Sprays small fading quads: smoke, sparks, dust, explosions. Particles live in world space, so a moving emitter leaves a trail. Call Burst from a script for one-off effects, or use BurstOnStart with DestroyWhenFinished in a prefab and spawn it.

Live particles aren’t saved, so rewinding during play clears them.

Works with: Lifetime (for one-off effects)

Draws itself (its entity draws at Order 0 unless it has a Sprite, whose order counts).

Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.

  • image: text = null. Image for each particle, relative to Assets. Without one, particles are solid squares. (A picture in Assets, e.g. “Sprites/back.png”.) (Field: an image.)
  • columns: a whole number = 1. For sprite sheets: frames across the image, as on a Sprite. 1 for a single image. (Field: a number.)
  • rows: a whole number = 1. For sprite sheets: frames down the image. (Field: a number.)
  • frame: a whole number = 0. Which frame of the sheet each particle shows, counting left to right, top to bottom from 0. Frames takes over when it’s set. (Field: a number.)
  • frames: text = null. Frames to use instead of Frame, written like an Animation clip’s: 0-1 is frames 0 and 1, 3-4, 7 is 3, 4 and 7, and 3-0 runs backward. Each particle picks one at random as it’s born (from the game’s random, so a rewound or networked game repeats), or with AnimateFrames steps through them. (Plain text: frame numbers and ranges, as an Animation clip writes them.) (Field: text.)
  • animateFrames: true or false = false. With Frames: each particle shows them in order, one after another across its life, instead of one picked at birth. (Only used when frames is set.) (Field: on or off.)
  • emitting: true or false = true. While set, emits Rate particles per second. (Field: on or off.)
  • rate: a number = 20. Particles per second while Emitting. (Only used when emitting is on.) (Field: a number.)
  • burstOnStart: a whole number = 0. Particles emitted at once when the game first runs this emitter (e.g. for an explosion prefab). (Field: a number.)
  • lifetime: a number = 1. Seconds each particle lives. (Field: a number.)
  • speed: a number = 3. Starting speed in world units per second. (Field: a number.)
  • speedVariation: a number = 0.5. How much each particle’s speed may differ, from 0 (all the same) to 1 (anywhere from 0 to double). (Field: a number.)
  • direction: a number = 90. Degrees: 0 is right, 90 is up. The entity’s rotation is added. (Field: a number.)
  • spread: a number = 30. Width of the spray in degrees around Direction; 360 sprays every way. (Field: a number.)
  • gravityScale: a number = 0. Multiplier on world gravity; 0 floats, 1 falls like a body. (Field: a number.)
  • startSize: a number = 0.3. Width and height in world units at birth. (Field: a number.)
  • endSize: a number = 0. Width and height in world units at the end of its life. (Field: a number.)
  • startColor: a color, “#RRGGBB” or “#RRGGBBAA” = “#FFFFFFFF”. Each particle’s color when it’s made. (Field: a color.)
  • endColor: a color, “#RRGGBB” or “#RRGGBBAA” = “#FFFFFF00”. Each particle’s color at the end of its life, blending from StartColor; a clear one fades it out. (Field: a color.)
  • order: a whole number = 0. Higher draws on top, like Sprite.Order. (Field: a number.)
  • destroyWhenFinished: true or false = false. Removes the entity once it has stopped emitting and its last particle is gone. (Field: on or off.)
  • maxParticles: a whole number = 500. The oldest particles make room for new ones beyond this many. (Field: a number.)

Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.

  • isFinished: true or false. True once there’s nothing left to show: the start burst has happened, the emitter isn’t emitting continuously, and every particle has died.

Scripts use it as ParticleEmitter: its methods, events and values that aren’t saved with the scene.