Ember is discontinued. It still works, but it gets no more updates or support. Back to uayi.org
Home · Terrified Gorillas · Glimmerwood · Starfall Hollow · ‹ Prev Next ›
Ember
Download

Making games

Particle effects

A Particle Effect is a component that throws out lots of small glowing or soft dots: fire, smoke, sparks, an explosion, rain. Effects play in the editor as well as in the game, so you see them while you place them.

Adding one

Presets

Preset
fire rising flames that glow and bloom
smoke slow grey puffs that grow and fade
sparks fast streaks that fall with gravity
explosion one big burst, then done
rain, snow weather over a 36 × 36 m area
dust motes drifting in the air (sunbeams, old rooms)
magic sparkles that float up and change colour
fountain a water jet that arcs and falls
confetti a burst of colourful pieces
steam white vapour from a vent or a kettle

Choosing a preset in the Inspector replaces the settings; everything below can then be tuned.

Settings

Group Settings
Emission emitting, rate (per second), burst (at the start), loop or duration, maximum particles
Shape and motion shape (point, sphere, box, cone), size, direction, spread, speed (+ random), gravity, drag, spin, world space
Look lifetime (+ random), size at start and end, colour and transparency at start and end, brightness, blending, stretch, texture
Realism a middle colour and size (start → middle → end, e.g. white-hot → orange → dark smoke), turbulence (swirling flames and curling smoke), soft edges (no hard line where particles meet the ground), lit by the scene (smoke takes the colour of the sun and nearby lights), flicker light (a light on the same object flickers like firelight)

Built-in textures: builtin:flame (tall flame tongues), builtin:smoke (soft billowing puffs), builtin:spark and builtin:dot. The presets pick the right one; choose another in Built-in texture, or use your own image.

The Restart and Burst buttons under the settings replay the effect while you tune it.

In scripts

-- an explosion where something was hit; it removes itself after 3 seconds
scene.spawn{ name = "Boom", position = hit.point, particles = "explosion", lifetime = 3 }

-- a custom effect: a preset plus changes
scene.spawn{ position = vec3(0, 1, 0), particles = { preset = "sparks", rate = 120, start_color = {0.4, 0.8, 1, 1} } }

local torch = scene.find("Torch")
torch.emitting = false            -- stop (the particles alive finish)
torch:emit(40)                    -- 40 particles right now, even when emitting is off
torch:set_particles("smoke")      -- switch to another preset
print(torch.particles)            -- how many are alive

The same settings, with underscores (start_size, end_color, world_space…), work in scene files and in MCP's set_components {"particles": {...}}.

Performance

Particles are simulated on the CPU and drawn in one batch per effect. A few thousand at once is fine. Rain uses up to 2,500, so keep heavy weather to one effect that follows the player.

Ember 1.1 documentation. Found a mistake? The source of this page is site/docs/particles.md in the Ember source.