Recipes
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.
- Give the object durability: seed a numeric field in a durable record for that object (for example
writeTypedStateValueahpof 3), keyed so each breakable tracks its own. - Take a hit: a projectile impact (see projectiles-and-ranged-weapons) or a contact trigger. Give the object a trigger
ColliderComponent(collision:"trigger") andaddTriggerHandler{ "handlerKey":"onHit" }, or apply damage from the projectile's own hit handler. - Subtract durability:
incrementNumericState{ "field":"hp", "by": -1 }per hit.readTypedStateValueit into a binding to test for break. - Break at zero: when
hpreaches 0,despawnEntitythe object andspawnEntityFromTemplatea debris or fractured-pieces prefab in its place; fire a burstParticleEmitterComponent(see particles-and-visual-effects) and optionally a scorchDecalComponent. - Drop loot: on break,
spawnEntityFromTemplatea pickup (see collectibles-and-scoring) oremitCustomEventabrokeevent 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
solidcollider 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_snapshotto confirm the hit handler and the break spawn are on the graph.