Skip to main content

soft_body_removal

Removing a soft-body (i.e., despawning its entity, or removing its SoftBody component) removes everything the engine created for it: its root body, the proxies of its clusters, the colliders of its surface and of its deformable meshes, as well as the joints attached to any of them. One cluster can also be removed on its own (by despawning its entity, or removing its SoftBodyCluster component):

fn remove_soft_bodies(
mut commands: Commands,
rope: Single<Entity, With<Rope>>,
cluster: Single<Entity, With<PlateCluster>>,
) {
// Despawning a soft-body entity (or removing its `SoftBody` component) removes its root
// body, its proxies, its colliders and the joints attached to them.
commands.entity(*rope).despawn();
// Despawning a cluster entity (or removing its `SoftBodyCluster` component) removes the
// cluster.
commands.entity(*cluster).despawn();
}
warning

Removing a cluster also removes the particles that only this cluster covered, with their elements and their attachments. Therefore removing the last cluster of a soft-body removes the soft-body itself. Note that removing the proxy of a cluster from the rigid-body set is equivalent to removing the cluster.