Exemple #1
0
        //Enable unity physics
        static public void UnFreezeItem(GameObject item)
        {
            Collider[] itemColliders = item.GetComponentsInChildren <Collider>();
            foreach (Collider col in itemColliders)
            {
                VRInteractableItem ii = null;
                VRItemCollider     ic = col.GetComponent <VRItemCollider>();
                if (ic != null)
                {
                    ii = ic.item;
                }
                if (ii == null)
                {
                    ii = col.GetComponent <VRInteractableItem>();
                }
                if (ii != null && (ii.parents.Count != 0 || !ii.enabled || ii.interactionDisabled))
                {
                    continue;
                }
                col.enabled = true;
            }
            RigidbodyMarker bodyMarker = item.GetComponent <RigidbodyMarker>();

            if (bodyMarker != null)
            {
                Rigidbody body = bodyMarker.ReplaceMarkerWithRigidbody();
                body.isKinematic = false;
            }
            else
            {
                Rigidbody body = item.GetComponent <Rigidbody>();
                if (body != null)
                {
                    body.isKinematic = false;
                }
            }

            /*Rigidbody itemBody = item.GetComponentInChildren<Rigidbody>();
             * if (itemBody != null)
             * {
             *      itemBody.useGravity = true;
             *      itemBody.isKinematic = false;
             *      itemBody.constraints = RigidbodyConstraints.None;
             *      itemBody.interpolation = RigidbodyInterpolation.Interpolate;
             * }*/
        }
Exemple #2
0
        //Set item up to be held correctly
        static public void HeldFreezeItem(GameObject item)
        {
            Collider[] itemColliders = item.GetComponentsInChildren <Collider>();
            foreach (Collider col in itemColliders)
            {
                VRInteractableItem ii = null;
                VRItemCollider     ic = col.GetComponent <VRItemCollider>();
                if (ic != null)
                {
                    ii = ic.item;
                }
                if (ii == null)
                {
                    ii = col.GetComponent <VRInteractableItem>();
                }
                if (ii != null && (ii.parents.Count != 0 || !ii.enabled || ii.interactionDisabled))
                {
                    continue;
                }
                col.enabled = true;
            }
            RigidbodyMarker bodyMarker = item.GetComponent <RigidbodyMarker>();

            if (bodyMarker != null)
            {
                Rigidbody body = bodyMarker.ReplaceMarkerWithRigidbody();
                body.isKinematic = false;
            }
            else
            {
                Rigidbody body = item.GetComponent <Rigidbody>();
                if (body != null)
                {
                    body.isKinematic = false;
                }
            }
        }