private void OnCollisionEnter(Collision other)
    {
        if (transform.parent == null)
        {
            return;
        }
        //Debug.Log(other.gameObject.tag);
        if (other.gameObject.CompareTag("AlienBullet") || other.gameObject.CompareTag("PlayerBullet"))
        {
            other.gameObject.tag = "Untagged";

            Transform parent = transform.parent;
            for (int i = parent.childCount - 1; i >= 0; i--)
            {
                ShieldModuleCollider moduleScript = parent.GetChild(i).gameObject.GetComponent <ShieldModuleCollider>();
                moduleScript.MakeInactive();
            }
            for (int i = parent.childCount - 1; i >= 0; i--)
            {
                Transform sibling = parent.GetChild(i);

                sibling.parent = null;
            }
        }
    }
Beispiel #2
0
    public void DestroyShield()
    {
        for (int a = 0; a < transform.childCount; a++)
        {
            Transform column = transform.GetChild(a);
            for (int i = column.childCount - 1; i >= 0; i--)
            {
                ShieldModuleCollider moduleScript = column.GetChild(i).gameObject.GetComponent <ShieldModuleCollider>();
                moduleScript.MakeInactive();
            }
            for (int i = column.childCount - 1; i >= 0; i--)
            {
                Transform sibling = column.GetChild(i);

                sibling.parent = null;
            }
        }
    }