Gessa Docs
Recipes

Recipe

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.

  1. 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).
  2. 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 addTickHandler that incrementNumericState their health field down by a per-second amount scaled by ctx.delta; on zero, run the death flow.
  3. Water look: attach a WaterComponent (set surfaceLevel, color, waveProfile) for the planar surface. It is a presentation component, not a physics volume; it does not by itself slow or drown anyone.
  4. Swim / drown logic: in a whole-body GessaScript body (replaceScriptFromGessaScript), call ctx.water.isSubmerged for the player's point or ctx.water.surfaceLevelAt to compare against their height, and react (buoyancy, an oxygen countdown, or damage below the surface).
  5. Telegraph the danger with particles-and-visual-effects (bubbles, embers) and a hazard-colored DecalComponent or HighlightComponent.

Pitfalls

  • WaterComponent renders water; it does NOT create a swim volume or apply drag. Any swim or drown effect is script logic keyed off ctx.water.*.
  • Hazard colliders must be trigger; a solid lava 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_snapshot to confirm the hazard triggers, handlers, and any WaterComponent are present.
Was this helpful?Report an issueContact support

On this page