Recipes
Hazards lava damage zones and water
The player touches lava and takes damage, falls into a pit and respawns, or wades into water. Damage on contact is a trigger plus a script (there is no
DamageOnContactComponent or HealthComponent); water look is a real WaterComponent, and a script can read submersion.engine v1.0.234since script-semantic-patch-ops.v1, action-catalog.v1.0.232, physics.v1, rendering.v1, persistence.v1, match.v1Copy for LLM
Use this for
lava, spikes, and out-of-bounds pits that hurt or kill on contact; damage-over-time zones; swimmable or deadly water; a kill floor that respawns the player
Not for
projectile or weapon damage (see projectiles-and-ranged-weapons); the health and respawn bookkeeping itself (see combat-damage-and-respawn); a decorative water look with no gameplay (attach WaterComponent alone)
Pairs with: Combat damage health and respawn scripting, Spawn points checkpoints and respawn flow, Moving platforms, elevators, rotating hazards, and objects on a patrol path, Particles explosions and visual effects
The recipe
Author with project_apply_script_semantic_patch using the ai_safe op pack.
- Instant kill floor / pit: a large flat entity with a trigger
ColliderComponent(collision:"trigger") under the level. On enter,addTriggerHandler{ "handlerKey":"onFallOut" }and respawn the player at the last checkpoint (see spawn-points-and-checkpoints and combat-damage-and-respawn). - Damage zone (lava, gas): a trigger over the danger area. Apply damage on enter for a hit, or for damage-over-time keep a set of entities currently inside (mark on enter, clear on exit) and
addTickHandlerthatincrementNumericStatetheirhealthfield down by a per-second amount scaled byctx.delta; on zero, run the death flow. - Water look: attach a
WaterComponent(setsurfaceLevel,color,waveProfile) for the planar surface. It is a presentation component, not a physics volume; it does not by itself slow or drown anyone. - Swim / drown logic: in a whole-body GessaScript body (
replaceScriptFromGessaScript), callctx.water.isSubmergedfor the player's point orctx.water.surfaceLevelAtto compare against their height, and react (buoyancy, an oxygen countdown, or damage below the surface). - Telegraph the danger with particles-and-visual-effects (bubbles, embers) and a hazard-colored
DecalComponentorHighlightComponent.
Pitfalls
WaterComponentrenders water; it does NOT create a swim volume or apply drag. Any swim or drown effect is script logic keyed offctx.water.*.- Hazard colliders must be
trigger; asolidlava slab blocks the player instead of hurting them. - Damage-over-time must scale by
ctx.delta; a flat per-tick subtraction kills faster on higher tick rates. - Store health in durable state and run death server-side; a client-only kill desyncs across players.
- The collision system caps at 1000 entities per tick; one big hazard trigger is far cheaper than hundreds of small overlapping ones.
Verify
simulation_run(qa.run.start) to prove contact damages or kills, a fall respawns the player, and submersion in water triggers the swim reaction.project_get_graph_snapshotto confirm the hazard triggers, handlers, and anyWaterComponentare present.