Ejemplo n.º 1
0
    // OnTriggerEnter() event listener.
    private void OnTriggerEnter(Collider other)
    {
        Transform otherTransform  = other.transform;
        Transform parentTransform = otherTransform.parent;

        CustomTag customTag = otherTransform.GetComponent(typeof(CustomTag)) as CustomTag;

        if (otherTransform.CompareTag(interactableTag) && customTag != null && customTag.hasTag(targetTag))
        {
            detachControllerObjects(otherTransform, parentTransform);

            // Destroy Other Children
            foreach (Transform child in otherTransform)
            {
                Destroy(child.gameObject);
            }

            // Destroy Other
            Destroy(otherTransform.gameObject);

            // Destroy Other Parent
            if (parentTransform != null)
            {
                Destroy(parentTransform.gameObject);
            }
        }
    }