Пример #1
0
    // Start is called before the first frame update
    void Awake()
    {
        for (int i = 0; i < transform.childCount; i++)
        {
            var child = transform.GetChild(i);
            var _pdc  = child.gameObject.AddComponent <PartialDestructionController>();
            child.gameObject.AddComponent <Rigidbody>();
            var _mc = child.gameObject.AddComponent <MeshCollider>();
            _mc.convex           = true;
            child.gameObject.tag = "Slicable";
            _destruction_pieces.Add(_pdc);
        }

        pdc_root = root.GetComponent <PartialDestructionController>();
    }
Пример #2
0
    private static void recursive_update(PartialDestructionController pdc)
    {
        if (!pdc.check_flag)
        {
            if (!pdc.is_connected)
            {
                return;
            }
            pdc.check_flag = true;

            foreach (var _pdc in pdc.connected_to)
            {
                recursive_update(_pdc);
            }
        }
        else
        {
            return;
        }
    }