A few small components round out the Toolkit: breakable objects with a clean destroy sequence, and components that hold a Rigidbody at a constant velocity.
Breakable #
Breakable swaps an intact object for a broken one, for example a whole vase for a pile of shards, when it takes a hard enough impact or when you call Break(). Put it on the object, assign the intact and broken GameObjects, and set what should happen next.
| Setting | Default | What it does |
|---|---|---|
unbroken | none | The intact version, deactivated on break. |
broken | none | The broken version, activated on break. |
parentRigidbody | none | An optional Rigidbody to freeze when the object breaks. |
breakForce | 0 | The relative speed of impact, in metres per second, that breaks the object. Zero disables impact breaking. |
addForce | 0 | A force added at the point of impact when breaking. Zero disables it. |
addForceRadius | 0 | The radius of that force. Zero disables it. |
disableTimer | 0 | Seconds after the break before the child Rigidbodies are disabled. Zero disables it. |
destroyTimer | 0 | Seconds after the break before the object is destroyed. Zero disables it. |
eventOnly | off | When on, a sufficient impact fires the Collision Break event but does not call Break(), so you can sync the break with a networking API. |
Events: collisionBreak (an impact was hard enough), breaking (the object broke), physicsDisabled (the pieces had their physics disabled) and destroying (the object is about to be destroyed). IsBroken is true once it has broken, and Break() breaks it now if it has not already. Breakable handles a missing intact object, broken object or events without error.
Destroy effects #
To replace the default destruction with something nicer, put a component implementing IDestroyEffect next to the Breakable. SinkingDestroy is the included one: it sinks the object before destroying it, good for wreckage.
SinkingDestroy setting | Default | What it does |
|---|---|---|
direction | (0, -1, 0) | The direction the object sinks in. |
speed | 0.25 | The speed it sinks at, in metres per second. |
duration | 5 | How long it sinks, in seconds, before it is destroyed. |
IsDestroying is true while it is sinking.
Constant velocity #
ConstantLinearVelocity and ConstantAngularVelocity hold a Rigidbody at a velocity by applying the force or torque needed to keep it there every fixed step. Set targetRelativeVelocity to the world-space velocity to hold: metres per second for linear, radians per second for angular. They are good for conveyors, spinning platforms and steady-speed movers.