Show an effect
Fire, explosions, smoke, sparks, beams: each is an effect you name in the view and play by name, from the rules (every player sees it) or from the client (this screen only). The client ships 38 ready-made ones.
Quick start
Take the ready-made effects you want into the view:
import { presetFx, type GameView } from '@v12-engine/client'
export const view: GameView = {
units: { looks: {} },
fx: { defs: presetFx(['explosion', 'fire', 'smoke', 'heal']) }
}Then play one from the rules, so every player who sees the spot sees it at the same moment (and in replays):
import type { Entity, World } from '@v12-engine/engine'
declare const world: World
declare const mine: Entity
world.fx('explosion', { at: { x: mine.pos.x, z: mine.pos.z }, params: { size: 2 } })A blast twice the made size, with its flash, fireball, sparks, smoke, shake and scorch mark. The client plays no effect the view doesn't have.
Common tasks
Play one on a unit
on follows the unit; point names a point of its model.
import type { Entity, World } from '@v12-engine/engine'
declare const world: World
declare const house: Entity
const id = world.fx('fire', { on: house, point: 'roof' })
world.stopFx(id, { fade: 1 })Play one on this screen only
From client code (a menu, a cinematic, a button), client.fx.play returns a handle you can tune and stop.
import type { GameClientApi } from '@v12-engine/client'
declare const client: GameClientApi
declare const unitId: number
const burn = client.fx.play('fire', { on: unitId, point: 'roof', params: { size: 2 } })
burn.set({ size: 0.5 }) // knobs change while it plays
burn.stop({ mode: 'fade', fade: 1 })
await burn.doneChange a ready-made effect
Give it knobs of your own, or make a new one from it with fx.extend.
import { fx, presetFx, type GameView } from '@v12-engine/client'
export const view: GameView = {
units: { looks: {} },
fx: {
defs: {
...presetFx(['fire', 'smoke'], { fire: { color: '#ffb050' } }),
'frost.fire': fx.extend('fire', { color: '#9fe8ff', tint: '#2a7fff', smoke: false })
}
}
}Show it only to some players, over the fog
import type { Entity, World } from '@v12-engine/engine'
declare const world: World
declare const shrine: Entity
world.fx('beam', { at: shrine.pos, to: [1, 2], overFog: true })Draw a beam between two units
Effects drawn between two points are played with their other end (toward). linkFx() adds three: ray (a pulsing beam), tether (a sagging rope), chain (a crackling bolt).
import { linkFx, presetFx, type GameView } from '@v12-engine/client'
import type { Entity, World } from '@v12-engine/engine'
export const view: GameView = { units: { looks: {} }, fx: { defs: { ...presetFx(), ...linkFx() } } }
declare const world: World
declare const caster: Entity
declare const target: Entity
world.fx('ray', { on: caster, toward: target })Play an effect on a game event
Declare it in the view by event id: an effect where the event says (x, z, or entity), a sound, a shake.
on: {
'mine.exploded': { fx: 'explosion', params: (event) => ({ size: event.power }), sound: 'boom', shake: 0.6 },
'wave.started': (event, client) => client.camera.lookAt(event.gate)
}Place an effect on the map
A campfire, a chimney's smoke, a waterfall's mist that play for as long as the map does: use the editor's effect tool (see below). They're saved in the map's file (MapEnvironment.fx), drawn for every player, and never seen by the rules. In a game, client.mapFx.named('campfire') gives what plays of one.
Give an ability or a shot an effect
See Ability visuals. An attack's shot carries one with ShotDef.fx and lands with ShotDef.impact.
Editor
Try any effect in a game:
- Open the debug panel (🐞, or Alt+Shift+D) and find Effects.
- Type a name or a word ("sparks", "magic") and pick one.
- Play it on the selected units, where the camera looks, or where I click (a projectile like
fireballis thrown there from the first selected unit). Shift keeps clicking; Esc stops. - Stop all stops what you played. It plays on this screen only.
Place one on the map:
- Press
X(the effect tool, sparkles on the strip) and click the map. - Drag to move,
[and]to turn; the handles move, turn and resize it. - In the Inspector, pick its effect, knobs,
when(always, at night, by day, between two hours) and from whichqualityit plays.
Tune or make one: the Effects panel, see Make your own effect.
Reference
Playing options
| Option | Rules world.fx | Client fx.play | What it does |
|---|---|---|---|
at | ✓ | ✓ | A place { x, z } (or with y) |
on | ✓ | ✓ | An entity to follow; ends with it unless stay |
point | ✓ | ✓ | A point of its model (roof, weapon) |
params | ✓ | ✓ | Knobs |
toward | ✓ | The other end of a beam: an entity or a place | |
to | ✓ | Only these players | |
overFog | ✓ | ✓ | Shown over the fog of war |
seed | ✓ | Same random choices every time |
world.fx returns an id for world.stopFx(id, { fade }). The client's FxHandle: set(params), stop({ mode, fade }) (at-once, fade, or finish, the default: what's alive ends by itself), hold(true | false) (freeze in place), move(to), done, alive, length, particles.
Things worth knowing
- An effect is hidden where the player can't see (the fog), and while the entity it is on isn't seen. Its sound isn't heard there either.
- Effects from the rules go to the screens of the players who see the spot or know the entity. Their random choices use a seed shared by every screen.
- Effects aren't in the world's state, a save, or sent to a player who joins later. What lasts shows through what the world keeps (a building's damaged look, a map's own effects).
- In code:
client.fx.define(name, def)defines one by name,GameView.fx.fordecides one by name before those declared,client.fx.play({ parts: [...] })plays one unnamed,client.fx.stats()says what's alive. client.debugTools.playFx(name, 'selected' | 'focus' | { x, z }, params)plays from code what the debug panel plays.GameView.hud.debug.hide: ['effects']hides that section.- A map's effects in code:
editor.doc.look.addFx(at, { fx }),look.setFx(id, change),look.removeFx(ids); a map's lasting marks (a scorch, a rune) are decals, not effects.
Ready-made effects
presetFx(names?, params?) takes them into the view (PRESET_FX). They use the pictures of @v12-engine/assets' fx group (Kenney's Particle Pack, CC0) where the game has the package, and pictures made in the page where it hasn't (ParticleDef.fallback). Each picture is at its default knobs, by day.
Fire
| Effect | Its knobs | |
|---|---|---|
![]() | fire: flames, embers, a flickering light, smoke over it | size (1); color ("#ff9a2e"): the flames' heart; tint ("#e8360c"): their tips; rate (60); light (1.4): 0 for none; smoke ({"darkness":0.55}): its knobs, or false; embers (true) |
![]() | torch: a small flickering flame with its light | size (0.35); color ("#ffb24a"); tint ("#ff5a18"); rate (40); light (1.1); smoke ({"darkness":0.3,"rate":3}); embers (false) |
![]() | campfire: flames, embers, a warm light, a little smoke | size (0.7); color ("#ffae45"); tint ("#ff4e12"); rate (45); light (1.8); smoke ({"darkness":0.45,"rate":6}); embers (true) |
![]() | embers: glowing embers rising off something burning | size (1); rate (8); color ("#ff8a30"); radius (0.6) |
![]() | burning-ground: ground on fire over a radius: low flames, smoke, a light, scorched after | radius (2); color ("#ffa640"); tint ("#ff4010"); rate (25); light (1.6); scorch (true) |
![]() | fire-trail: fire left behind what moves: flames that burn out, embers, smoke, scorched ground. On a unit, it follows | size (1); color ("#ffae3c"); tint ("#ff3d0c"); rate (70); light (1.2); smoke, embers, scorch (true) |
Smoke
| Effect | Its knobs | |
|---|---|---|
![]() | smoke: a column rising and drifting with the wind | size (1); darkness (0.4): 0 white steam to 1 black smoke; rate (12); color ("#b4aea5") |
![]() | puff: one puff: a shot, a landing, a unit appearing | size (1); color ("#bdb6aa"); amount (10) |
![]() | chimney: thin smoke from a chimney, a pipe, a lamp | size (0.45); darkness (0.35); rate (4); color ("#9c968e") |
![]() | smoke-trail: smoke left behind what flies or burns (a rocket, a flaming piece) | size (1); rate (30); color ("#57524c") |
Explosions
| Effect | Its knobs | |
|---|---|---|
![]() | explosion: a flash, a fireball, sparks and smoke, a shockwave, a light, the view shaken, the ground scorched | size (1); color ("#ffb24a"): the fireball's heart; tint ("#ff4a10"): its edge and sparks; light (5); shake (0.6): 0 for none; scorch (true); sound (none): a sound of the game's (GameView.sounds) |
![]() | shockwave: a ring flung out along the ground, with dust | size (1); color ("#fff0d0"); dust (true) |
![]() | fireball: a white-hot heart in rolling flames, sparks, smoke, a streak. Moved, it trails; impact is what it lands with | size (1); color ("#ffc24a"); tint ("#ff4a0c"); light (1.8); smoke, streak (true); impact ("explosion"); impactSize (0.6) |
![]() | impact-ring: a flash and two rings racing out over the ground, dust and sparks, the ground cracked | size (1); color ("#ffe4a8"); tint ("#ff8a2a"); speed (1); light (3); shake (0.35); dust, sparks, crack (true); sound (none) |
![]() | spark-burst: sparks flung out: steel on steel, a hammer on stone | size (1); count (24); color ("#ffd27a"); sound (none) |
Dust and earth
| Effect | Its knobs | |
|---|---|---|
![]() | dust: a cloud thrown up: an impact, a fall, a building coming down | size (1); amount (18); color ("#9a8466"); bits (true): bits of dirt fly too |
![]() | dust-trail: dust kicked up behind feet or wheels. On a unit, it follows | size (1); rate (14); color ("#a08a6a") |
![]() | leaves: leaves flung up and fluttering down (FoliageLook.leaves, a tree struck) | size (1); amount (10); color ("#4f7a2a"); tint ("#a8a03a"): the odd dry leaf |
![]() | rubble-fall: rubble falling from a height, dust where it lands | size (1); height (3); amount (24); color ("#8a7a68") |
![]() | ground-crack: the ground cracked open, dust and bits thrown up | size (1); color ("#2c241c"); time (20): how long the cracks stay |
Magic
| Effect | Its knobs | |
|---|---|---|
![]() | glow: a soft breathing orb with its light: a wisp, a lantern of magic | size (1); color ("#7fd0ff"); light (1); height (1) |
![]() | sparkle: twinkles of light: treasure, a blessing | size (1); color ("#fff2a0"); rate (14) |
![]() | aura: a turning ring of light under a unit, motes rising | size (1); color ("#ffd76a") |
![]() | beam: a pillar of light from the sky | size (1); color ("#fff4c0"); height (12); light (3) |
![]() | portal: a swirl on the ground, motes drawn in, its light | size (1); color ("#b07aff"); light (2) |
![]() | heal: ribbons winding up a unit, a column of light, rising rings, crosses, a green glow and flash | size (1); color ("#42ff6e"); accent ("#f0ffd0"); rate (40); light (2.2); rings (3); spirals (true); crosses (true); sound (none) |
![]() | essence: ribbons of magic circling a unit, weaving over and under, sparkles trailing, closing in and gone | size (1); palette (eight colours); strands (5, up to 8); time (4); fade (1.6); turns (0.8) a second; radius (1); flat (0.5); wave (1); height (1); width (1); sparkles (30); light (1.2) |
![]() | sunburst: turning rays of sunlight around a unit, a bright heart, the ground lit | size (1); color ("#ffe9a0"); tint ("#ffb43c"); rays (22); spin (0.25); height (1.1); light (3) |
![]() | lightning: a bolt striking, a flash, sparks, the view shaken | size (1); color ("#bfe0ff"); light (8); shake (0.4); sound (none) |
![]() | frost: a burst of cold, glinting ice, a ring of rime on the ground | size (1); color ("#bfeaff") |
![]() | poison-cloud: a low drifting cloud of poison | radius (2.5); color ("#b8f060"); rate (12) |
![]() | gas-cloud: thick green gas rolling low, a sickly glow, fumes, bubbles popping, its edge marked | radius (3); color ("#5f9e2a"); tint ("#c6ff4a"); density (1); bubbles (14); height (1); light (0.8); edge (true) |
Water
| Effect | Its knobs | |
|---|---|---|
![]() | splash: drops thrown up and a ring of ripple | size (1); color ("#d6ecff"); sound (none) |
![]() | ripple: rings spreading on still water | size (1); color ("#d6ecff"); rate (1.2) |
![]() | mist: mist lying low: a waterfall's spray, a marsh | radius (3); color ("#eef4f8"); rate (6); opacity (0.3) |
Blood
| Effect | Its knobs | |
|---|---|---|
![]() | blood-spray: blood from a hit or death: long drops, finer ones, globs, a red mist | amount (14); color ("#730508"); tint ("#400305"); speed (3.5); height (1); size (1); mist (true) |
![]() | blood-burst: an explosion of blood: jets, mist, chunks, the ground splattered | size (1); amount (120); color ("#7a0609"); tint ("#3e0204"); speed (6); height (0.9); mist, chunks, splatter (true); shake (0.1); sound (none) |
![]() | blood-splatter: splats thrown over the ground, a pool, drops, drying away | size (1); count (9); spread (1.8); color ("#2c0103"); seconds (25); drops (true) |
![]() | blood-pool: a pool of blood drying away | size (1.1); color ("#730508"); seconds (30) |
The client's blood (GameView.units.blood) plays blood-spray, blood-pool where a unit falls, and blood-splatter away from the blow (BloodLook.spray, bloodFor).






































