//--------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------- public void SetDestroyed() { if (!s_fragments) { var fragments = new GameObject("Fragments"); s_fragments = fragments.transform; } foreach (var activate in ActivateOnDestroyed) { if (activate && !activate.activeInHierarchy) { activate.SetActive(true); } } foreach (var deactivate in DeactivateOnDestroyed) { if (deactivate && deactivate.activeInHierarchy) { deactivate.SetActive(false); } } foreach (var joint in jointBreaks) { if (joint) { Destroy(joint); } } foreach (var rbody in ejectedBodies) { if (!rbody) { continue; } rbody.constraints = RigidbodyConstraints.None; m_startingParent = rbody.transform.parent; rbody.transform.SetParent(s_fragments); Destroy(rbody.gameObject, fragmentLifetime); } OnDestroyed.Invoke(); if (useExplosion) { explosiveEffect.Initilize(explosionOrigin, explosiveEffect.m_profile); explosiveEffect.Detonate(); } }
public void Explode() { explosiveEffect.Detonate(); }