Exemple #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Limb" && !occupied)
        {
            Arm_2 arm  = collision.gameObject.GetComponent <Arm_2>();
            Leg   leg  = collision.gameObject.GetComponent <Leg>();
            Head  head = collision.gameObject.GetComponent <Head>();

            if (arm == null && head == null)
            {
                Foot foot = leg.foot;
                //leg.AttachLeg(this);
                foot.AttachLeg(this);
                attachedFoot = foot;
                occupied     = true;
            }
            else if (leg == null && arm == null)
            {
                Debug.LogWarning("Ayy");
                head.AttachHead(this);
                attachedHead = head;
                occupied     = true;
            }
            else
            {
                arm.AttachArm(this);
                attachedArm = arm;
                occupied    = true;
            }
        }
    }