示例#1
0
        //-------------------------------------------------
        private void HandAttachedUpdate(Hand hand)
        {
            //Trigger got released
            if (!hand.GetStandardInteractionButton())
            {
                // Detach ourselves late in the frame.
                // This is so that any vehicles the player is attached to
                // have a chance to finish updating themselves.
                // If we detach now, our position could be behind what it
                // will be at the end of the frame, and the object may appear
                // to teleport behind the hand when the player releases it.
                StartCoroutine(LateDetach(hand));
            }

            if (attachEaseIn)
            {
                float t = Util.RemapNumberClamped(Time.time, attachTime, attachTime + snapAttachEaseInTime, 0.0f, 1.0f);
                if (t < 1.0f)
                {
                    t = snapAttachEaseInCurve.Evaluate(t);
                    transform.position = Vector3.Lerp(attachPosition, attachEaseInTransform.position, t);
                    transform.rotation = Quaternion.Lerp(attachRotation, attachEaseInTransform.rotation, t);
                }
                else if (!snapAttachEaseInCompleted)
                {
                    gameObject.SendMessage("OnThrowableAttachEaseInCompleted", hand, SendMessageOptions.DontRequireReceiver);
                    snapAttachEaseInCompleted = true;
                }
            }
        }
示例#2
0
        //-------------------------------------------------
        private void OnHandHoverBegin(Hand hand)
        {
            bool showHint = false;

            // "Catch" the throwable by holding down the interaction button instead of pressing it.
            // Only do this if the throwable is moving faster than the prescribed threshold speed,
            // and if it isn't attached to another hand
            if (!attached)
            {
                if (hand.GetStandardInteractionButton())
                {
                    Rigidbody rb = GetComponent <Rigidbody>();
                    if (rb.velocity.magnitude >= catchSpeedThreshold)
                    {
                        hand.AttachObject(gameObject, attachmentFlags, attachmentPoint);
                        showHint = false;
                    }
                }
            }

            if (showHint)
            {
                ControllerButtonHints.ShowButtonHint(hand, EVRButtonId.k_EButton_SteamVR_Trigger);
            }
        }
示例#3
0
        //-------------------------------------------------
        private void Pulse()
        {
            if (hand && (hand.controller != null) && (hand.GetStandardInteractionButton()))
            {
                ushort duration = (ushort)Random.Range(minimumPulseDuration, maximumPulseDuration + 1);
                hand.controller.TriggerHapticPulse(duration);

                onPulse.Invoke();
            }
        }
示例#4
0
        //-------------------------------------------------
        private void OnHandHoverEnd(Hand hand)
        {
            ControllerButtonHints.HideButtonHint(hand, EVRButtonId.k_EButton_SteamVR_Trigger);

            if (driving && hand.GetStandardInteractionButton())
            {
                StartCoroutine(HapticPulses(hand.controller, 1.0f, 10));
            }

            driving         = false;
            handHoverLocked = null;
        }
示例#5
0
        //-------------------------------------------------
        private void HandHoverUpdate(Hand hand)
        {
            if (hand.GetStandardInteractionButtonDown())
            {
                hand.HoverLock(GetComponent <Interactable>());

                initialMappingOffset = linearMapping.value - CalculateLinearMapping(hand.transform);
                sampleCount          = 0;
                mappingChangeRate    = 0.0f;
            }

            if (hand.GetStandardInteractionButtonUp())
            {
                hand.HoverUnlock(GetComponent <Interactable>());

                CalculateMappingChangeRate();
            }

            if (hand.GetStandardInteractionButton())
            {
                UpdateLinearMapping(hand.transform);
            }
        }