This commit is contained in:
2025-09-17 18:56:28 +08:00
commit 54c72710a5
5244 changed files with 5717609 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
using UnityEngine;
namespace DestroyIt
{
/// <summary>
/// Place this script on a rigidbody parent that has one or more compound collider Destructible children under it.
/// Example: the SUV in the showcase demo scene. It is a rigidbody parent but not Destructible itself. But it has many child colliders that are destructible objects.
/// </summary>
public class DestructibleParent : MonoBehaviour
{
private void OnCollisionEnter(Collision collision)
{
if (collision.contacts.Length == 0) return;
Destructible destructibleObj = collision.contacts[0].thisCollider.gameObject.GetComponentInParent<Destructible>();
if (destructibleObj != null)
{
Rigidbody otherRbody = collision.contacts[0].otherCollider.attachedRigidbody;
if (otherRbody != null)
destructibleObj.ProcessDestructibleCollision(collision, otherRbody);
else
destructibleObj.ProcessDestructibleCollision(collision, this.GetComponent<Rigidbody>());
}
}
}
}