Events and Triggers
A trigger is a condition and the actions to take when it holds, stored in the scene as data. The engine evaluates triggers after every coupling step, so a trigger fires at the step it should, not at the next frame a graph happens to look, and a run with triggers is as deterministic as one without. Both graph styles use the same triggers: a functional result and a stepped session record the same events.
Conditions and actions below are those of the scene nodes. The real-time scenes have trigger nodes of their own (
AddLiquidTrigger,AddSmokeTrigger,AddOceanTrigger,AddShoreTrigger); see the Physics toolbox.
1. Conditions and actions
| Conditions | |
|---|---|
AtTime(time) |
a moment |
Every(interval, start 0, until ∞) |
a timer; always repeats |
OnContact(body, other "", minSpeed 0) |
a body starts touching another, or anything; optionally only above an approach speed |
Below(body, height), Above(body, height) |
a body crosses a height |
FasterThan(body, speed) |
a body's speed passes a threshold |
WaterInRegion(regionMin, regionMax, particles 1) |
at least n water particles in a box |
| Actions | |
|---|---|
Detonate(position, tntKg, atEvent false) |
a blast every solver feels, with fracture; with atEvent, the position is an offset from where the trigger fired |
Release(body) |
a static or kinematic body (and its spawned copies) becomes dynamic |
Push(body, impulse) |
a kick or a thrust (N·s) |
SetWind(velocity) |
changes the steady wind |
Spawn(body, atEvent false, scatter 0) |
adds a copy of a body, named body#1, body#2 …; scatter is the half-size of a box the position is scattered in, with the scene's seed |
UnpinCloth(cloth) |
lets go of a cloth's pinned vertices |
Remove(body, atEvent false) |
takes a body (and its spawned copies) out of the scene; with atEvent, only the event's own body, such as the raindrop that just landed |
| Building triggers | |
|---|---|
When(name, condition, action, repeat false, cooldown 0) |
a trigger; a repeating one fires every time the condition holds again, then stays quiet for cooldown seconds |
Watch(name, condition, repeat false) |
a trigger that only records events |
Also(trigger, action) |
the trigger with one more action |
AddTrigger(scene, trigger) |
puts it into a scene |
A condition that names a body also matches every copy spawned from it, so one trigger follows every raindrop of a shower.
2. How triggers are evaluated
After each coupling step, on one thread, in the order the triggers were added:
- Every condition is tested against the state that step produced.
- Then the actions of everything that fired are taken. A body a trigger spawns, or a blast it sets off, does not change what the other conditions of the same step saw.
- Contact conditions read the rigid world's contact events of that step.
- Threshold conditions are edge-triggered per body: they fire when a body crosses, not on every step it stays across.
- Timers fire once per interval that has elapsed.
Each firing is recorded as a SimulationEvent: Trigger (its name), Time, Position (the contact point, the body, or the region's centre), Body and Other, and a Value (the approach speed, the height, the count). Read them with Events, EventsOf and FirstEventTime from a result, or with TakeEvents from a session.
3. How accurate they are
Measured with the package:
| Case | Measured | Reference |
|---|---|---|
| Ball dropped from 1.25 m, contact trigger | fires at 0.492 s, approach speed 4.74 m/s | free fall: 0.495 s, √(2gh) = 4.85 m/s |
| Dam break 0.15 m wide, sensor box 0.35 m away | floods at 0.238 s | |
| Timer every 0.1 s spawning scattered drops | exactly five drops in 0.45 s; a repeating contact trigger reports each landing | |
| 0.2 kg charge 0.3 m under a crate as it falls past 1 m | moves the crate's resting place by 1.04 m | the same charge at the crate's centre: 0 m |
A contact is found by the rigid solver's speculative contacts, up to a step before the touch, so a contact point can sit a little above the surface (2.5 cm in the drop above).
4. Continuously triggered effects
Effects that keep happening are triggers that repeat:
- Rain on the ground:
When("rain", Every(0.01), Spawn(drop, scatter: area))andWatch("splash", OnContact("drop", "ground"), repeat: true); the splash events place splashes. - A charge where a crate passes a height:
When("blast", Below("crate", 1), Detonate(offset, 0.2, atEvent: true)). - A hammer cracking the ground: a kinematic hammer moved by the graph,
When("impact", OnContact("hammer", "ground", minSpeed: 5), Detonate(offset, kg, atEvent: true)), with the ground built from breakable rigid pieces.
Compared with Houdini
Houdini drives continuous effects through time (parameters as expressions of $F and $T, activation expressions on DOP nodes) and attributes (a packed piece simulated while active is 1, glue that breaks above its strength, wrangles over every point every step). Continuum's triggers hold both in a form a node graph can carry: AtTime and Every are the time-dependent activation; conditions on a body or a field are the per-element test; and the actions switch state the solvers honour every step, as Houdini's attributes do. Release is active going from 0 to 1, UnpinCloth breaks a constraint, Spawn emits. What Houdini writes as a wrangle over every point, a trigger states once and the engine applies to every body it names, including those spawned later.
5. Limits
- Conditions are fixed kinds; there is no expression language yet. Whether conditions and actions should accept Divooka
Funcsubgraphs (arbitrary tests, at the cost of graph code running inside every coupling step) is an open question. - Actions take constant parameters or the event's position; an action that scales with the event (a splash that grows with the impact speed) needs an expression too.
- Field conditions cover water particles; smoke density, FEM stress and flow velocity conditions come with those solvers' nodes.
- Triggers fire at coupling-step resolution.
- A blast needs a surface facing it: a charge exactly at a body's centre does not move that body, so give
Detonatean offset.