Beispiel #1
0
    public void Reset()
    {
        cCS = transform.parent.GetComponent <Scr_Connect_System>();

        if (cRB == null)
        {
            // If no rigidbody is on this object, check if any parent has one
            cRB = this.transform.root.GetComponentInChildren <Rigidbody>();
            // if there is still no rigidbody then be the rigidbody
            if (cRB == null)
            {
                cRB = this.transform.root.gameObject.AddComponent <Rigidbody>();
            }
        }

        cMC = this.GetComponent <MeshCollider>();

        if (cMC == null)
        {
            cMC = this.gameObject.AddComponent <MeshCollider>();
        }
        cMC.convex = true;

        cSS = this.GetComponent <Scr_Socket_System>();

        this.tag = "Grabbable";
    }
    public void DetachSelf()
    {
        // Get The Top parent
        Scr_Connect_System tRoot = this.transform.root.gameObject.GetComponent <Scr_Connect_System>();

        // Update mechanism system if present

        if (vConnectedToFemale != null)
        {
            vConnectedToFemale.vIsConnected = false;
        }

        // Detach Self
        this.transform.SetParent(null);
        foreach (Scr_PartParenting tObj in vMainParts)
        {
            tObj.ResetParent();
            // Old Gameobject style parenting
            //tObj.transform.SetParent(this.gameObject.transform);
        }

        // Update Parent after removal
        if (tRoot != null)
        {
            if (tRoot != this)
            {
                tRoot.transform.SetParent(vGameController.transform);
                tRoot.transform.SetParent(null);
            }
        }
    }
Beispiel #3
0
    void Reset()
    {
        cCS = transform.parent.GetComponent <Scr_Connect_System>();

        if (cRB == null)
        {
            cRB = this.transform.root.gameObject.AddComponent <Rigidbody>();
        }

        cMC = this.GetComponent <MeshCollider>();

        if (cMC == null)
        {
            cMC = this.gameObject.AddComponent <MeshCollider>();
        }
        cMC.convex = true;

        cSS = this.GetComponent <Scr_Socket_System>();

        this.tag = "Grabbable";
    }