In the video “Destructible Crate Parts”, is not added the same random way of exploding the crates, same as we do with the ragdolls when they fall.
If you are interested, you just need to add 1 line and modify another one from the “Damage()” method. Here is the full method, with comments:
public void Damage()
{
// Instantiate the crateDestroyedPrefab in the same position and rotation of the original crate
Transform crateDestroyedTransform = Instantiate(crateDestroyedPrefab, transform.position, transform.rotation);
// Apply the explosion force on the CrateDestroyed children parts.
Vector3 randomDir = new Vector3(UnityEngine.Random.Range(-1, +1), 0, UnityEngine.Random.Range(-1, +1));// To add some randomDir in the cratePartes children when they will explode.
ApplyExplosionToChildren(crateDestroyedTransform, 150f, transform.position + randomDir, 10f);
// Destroy the original crate.
Destroy(gameObject);
OnAnyDestroyed?.Invoke(this, EventArgs.Empty);
}
I hope you might find it useful!