---
title: "Hazards lava damage zones and water"
description: "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."
engineVersion: v1.0.234
date: 2026-09-28
license: "(c) Gessa, proprietary. Cite with attribution to https://gessa.ai/docs/. Terms: https://gessa.ai/terms/."
canonical: https://gessa.ai/docs/knowledge/playbooks/hazards-water-and-damage-zones/
---

# Hazards lava damage zones and water

## When to use

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.

## 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.
