Gessa Docs
Recipes

Recipe

Destructibles breakable crates walls and debris

A crate splinters when shot, a wall crumbles under fire, a barrel bursts. A breakable is the combat health loop applied to a world object: durability in state, damage on hit, break at zero. There is no DestructibleComponent or HealthComponent (stripped).
engine v1.0.234since script-semantic-patch-ops.v1, action-catalog.v1.0.232, persistence.v1, physics.v1, rendering.v1, spawn.v1Copy for LLM

Use this for

crates, barrels, and walls that break when hit or shot; objects with hitpoints that shatter; spawning debris or loot on break; demolishing cover

Not for

player or enemy health and respawn (see combat-damage-and-respawn); a collectible that vanishes on touch with no damage (see collectibles-and-scoring); a door that opens rather than breaks (see doors-buttons-and-interactions)

Pairs with: Combat damage health and respawn scripting, Projectiles bullets and ranged weapons, Particles explosions and visual effects, Collectibles pickups scoring and win condition

The recipe

Author with project_apply_script_semantic_patch using the ai_safe op pack.

  1. Give the object durability: seed a numeric field in a durable record for that object (for example writeTypedStateValue a hp of 3), keyed so each breakable tracks its own.
  2. Take a hit: a projectile impact (see projectiles-and-ranged-weapons) or a contact trigger. Give the object a trigger ColliderComponent (collision:"trigger") and addTriggerHandler { "handlerKey":"onHit" }, or apply damage from the projectile's own hit handler.
  3. Subtract durability: incrementNumericState { "field":"hp", "by": -1 } per hit. readTypedStateValue it into a binding to test for break.
  4. Break at zero: when hp reaches 0, despawnEntity the object and spawnEntityFromTemplate a debris or fractured-pieces prefab in its place; fire a burst ParticleEmitterComponent (see particles-and-visual-effects) and optionally a scorch DecalComponent.
  5. Drop loot: on break, spawnEntityFromTemplate a pickup (see collectibles-and-scoring) or emitCustomEvent a broke event a manager listens for.

Pitfalls

  • Store durability in state, not on a component; there is no health field on the entity, and a value written only on the entity is lost when it despawns.
  • The break must run server-side; a client-only smash desyncs which objects are gone across players.
  • Debris entities count against the 1000 per-tick budget; despawn debris on a short lifetime timer so shattering a room does not flood the world.
  • A breakable that should block until broken needs a solid collider for the intact object; swap or despawn it on break so the path opens.

Verify

  • simulation_run (qa.run.start) to prove hits lower durability and the object breaks into debris at zero.
  • project_get_graph_snapshot to confirm the hit handler and the break spawn are on the graph.
Was this helpful?Report an issueContact support

On this page