virtual public void Reset()
 {
     interactionDisabled = false;
     if (item != null)
     {
         VRInteractableItem.UnFreezeItem(item.gameObject);
     }
 }
示例#2
0
        virtual public void Drop(bool addControllerVelocity, VRInteractor hand = null)
        {
            if (canBeHeld && item != null)
            {
                item.parent = null;
                switch (getHoldType)
                {
                case HoldType.FIXED_POSITION:
                case HoldType.PICKUP_POSITION:
                    VRInteractableItem.UnFreezeItem(item.gameObject);
                    if (selfBody != null)
                    {
                        if (hand != null && addControllerVelocity)
                        {
                            bool useBoost = hand.Velocity.magnitude > 1f;
                            selfBody.velocity           = hand.Velocity * (useBoost ? getThrowBoost : 1f);
                            selfBody.angularVelocity    = hand.AngularVelocity;
                            selfBody.maxAngularVelocity = selfBody.angularVelocity.magnitude;
                        }
                    }
                    break;

                case HoldType.SPRING_JOINT:
                    for (int i = _heldBys.Count - 1; i >= 0; i--)
                    {
                        if (_heldBys[i] != hand)
                        {
                            continue;
                        }
                        _heldBys.RemoveAt(i);
                        Destroy(_springJoints[i]);
                        _springJoints.RemoveAt(i);
                    }
                    Rigidbody controllerBody = hand.getControllerAnchorOffset.GetComponent <Rigidbody>();
                    if (controllerBody != null)
                    {
                        Destroy(controllerBody);
                    }
                    break;
                }
                PlaySound(dropSound);
            }
            CheckIK(false, hand);
            if (dropEvent != null)
            {
                dropEvent.Invoke();
            }
            heldBy = null;
        }
        virtual public void Drop(bool addControllerVelocity, VRInteractor hand = null)
        {
            if (canBeHeld && item != null)
            {
                if (hand != null)
                {
                    NetworkIdentity ident = item.GetComponent <NetworkIdentity>();
                    if (ident != null)
                    {
                        NetworkedCameraRig networkedRig = hand.GetVRRigRoot.GetComponent <NetworkedCameraRig>();
                        if (networkedRig != null && networkedRig.connection != null && networkedRig.connection.isLocalPlayer)
                        {
                            ident.RemoveClientAuthority(networkedRig.connection.connectionToClient);
                        }
                    }
                }

                item.parent = null;
                switch (holdType)
                {
                case HoldType.FIXED_POSITION:
                case HoldType.PICKUP_POSITION:
                    VRInteractableItem.UnFreezeItem(item.gameObject);
                    if (_selfBody != null && addControllerVelocity)
                    {
                        if (hand != null)
                        {
                            bool useBoost = hand.Velocity.magnitude > 1f;
                            _selfBody.velocity           = hand.Velocity * (useBoost ? throwBoost : 1f);
                            _selfBody.angularVelocity    = hand.AngularVelocity;
                            _selfBody.maxAngularVelocity = _selfBody.angularVelocity.magnitude;
                        }
                    }
                    break;

                case HoldType.SPRING_JOINT:
                    for (int i = _heldBys.Count - 1; i >= 0; i--)
                    {
                        if (_heldBys[i] != hand)
                        {
                            continue;
                        }
                        _heldBys.RemoveAt(i);
                        Destroy(_springJoints[i]);
                        _springJoints.RemoveAt(i);
                    }
                    Rigidbody controllerBody = hand.getControllerAnchorOffset.GetComponent <Rigidbody>();
                    if (controllerBody != null)
                    {
                        Destroy(controllerBody);
                    }
                    break;
                }
                PlaySound(dropSound);
            }
            CheckIK(false, hand);
            if (dropEvent != null)
            {
                dropEvent.Invoke();
            }
            heldBy = null;
        }