Class DetachChildItemsOnDeath
Attach to a destructible plant (or any destructible prop) that has ItemBehaviour children representing collectible fruit/produce.
When the parent dies, this component un-parents every child item and enables its Rigidbody so the items fall naturally to the ground and become interactive pickups.
Execution order relative to DestructibleBehaviour:
Both subscribe to HealthBehaviour.Died. This component runs first
(Default Execution Order = -10) to un-parent children before
DestructibleBehaviour destroys the parent object.
[DefaultExecutionOrder(-10)]
[RequireComponent(typeof(HealthBehaviour))]
public class DetachChildItemsOnDeath : MonoBehaviour
- Inheritance
-
objectDetachChildItemsOnDeath