Example #1
0
        /// <summary>
        /// Try to release items
        /// </summary>
        private void UpdateReleaseObjects()
        {
            if (_grabbedItem == null || !HandData.ValidOutput(DeviceType))
            {
                return;
            }
            if (_grabbedItem != null && _grabbedItem.Hand != this)
            {
                return;
            }

            // Release item when the hand is completely open
            if (HandData.HandOpened(DeviceType))
            {
                Debug.Log("Released because the hand was fully open");
                //ReleaseItem();
            }

            //// *********************************
            // Edited by Murray Sandmeyer
            // Before: if ( HandData.FirstJointAverage(DeviceType) < _averageOnGrab )
            // This other option makes grabbing and releasing more consistent
            if (HandData.Average(DeviceType) < 0.2 && releaseEnabled)
            {
                ReleaseItem();
                //Debug.Log("Release this item " + HandData.Average(DeviceType) + " - " + _averageOnGrab);
            }
        }
        public override bool IsHandDetected(Hand handId)
        {
#if VRTK_DEFINE_SDK_MANUS_VR
            return(handData.ValidOutput(HandToDeviceType(handId)));
#else
            return(false);
#endif
        }
        /// <summary>
        /// Try to release items
        /// </summary>
        private void UpdateReleaseObjects()
        {
            if (_grabbedItem == null || !HandData.ValidOutput(DeviceType))
            {
                return;
            }
            if (_grabbedItem != null && _grabbedItem.Hand != this)
            {
                return;
            }

            // Release item when the hand is completely open
            if (HandData.HandOpened(DeviceType))
            {
                Debug.Log("Released because the hand was fully open");
                //ReleaseItem();
            }

            if (HandData.FirstJointAverage(DeviceType) < _averageOnGrab)
            {
                ReleaseItem();
                //Debug.Log("Release this item " + HandData.Average(DeviceType) + " - " + _averageOnGrab);
            }
        }