コード例 #1
0
 private void Update()
 {
     if (this.renderModel != null && this.renderModel.gameObject.activeInHierarchy && this.flashingRenderers.Count > 0)
     {
         Color color = this.controllerMaterial.GetColor(this.colorID);
         float num   = (Time.realtimeSinceStartup - this.startTime) * 3.14159274f * 2f;
         num = Mathf.Cos(num);
         num = Util.RemapNumberClamped(num, -1f, 1f, 0f, 1f);
         float num2 = Time.realtimeSinceStartup - this.startTime;
         if (num2 - this.tickCount > 1f)
         {
             this.tickCount += 1f;
             SteamVR_Controller.Device device = SteamVR_Controller.Input((int)this.renderModel.index);
             if (device != null)
             {
                 device.TriggerHapticPulse(500, EVRButtonId.k_EButton_Axis0);
             }
         }
         for (int i = 0; i < this.flashingRenderers.Count; i++)
         {
             Renderer renderer = this.flashingRenderers[i];
             renderer.material.SetColor(this.colorID, Color.Lerp(color, this.flashColor, num));
         }
         if (this.initialized)
         {
             foreach (KeyValuePair <EVRButtonId, ControllerButtonHints.ButtonHintInfo> keyValuePair in this.buttonHintInfos)
             {
                 if (keyValuePair.Value.textHintActive)
                 {
                     this.UpdateTextHint(keyValuePair.Value);
                 }
             }
         }
     }
 }
コード例 #2
0
        //-------------------------------------------------
        private void UpdateTextHint(ActionHintInfo hintInfo)
        {
            Transform playerTransform = player.hmdTransform;
            Vector3   vDir            = playerTransform.position - hintInfo.canvasOffset.position;

            Quaternion standardLookat   = Quaternion.LookRotation(vDir, Vector3.up);
            Quaternion upsideDownLookat = Quaternion.LookRotation(vDir, playerTransform.up);

            float flInterp;

            if (playerTransform.forward.y > 0.0f)
            {
                flInterp = Util.RemapNumberClamped(playerTransform.forward.y, 0.6f, 0.4f, 1.0f, 0.0f);
            }
            else
            {
                flInterp = Util.RemapNumberClamped(playerTransform.forward.y, -0.8f, -0.6f, 1.0f, 0.0f);
            }

            hintInfo.canvasOffset.rotation = Quaternion.Slerp(standardLookat, upsideDownLookat, flInterp);

            Transform lineTransform = hintInfo.line.transform;

            hintInfo.line.useWorldSpace = false;
            hintInfo.line.SetPosition(0, lineTransform.InverseTransformPoint(hintInfo.textStartAnchor.position));
            hintInfo.line.SetPosition(1, lineTransform.InverseTransformPoint(hintInfo.textEndAnchor.position));
        }
コード例 #3
0
        //-------------------------------------------------
        private void HandAttachedUpdate(Hand hand)
        {
            //Trigger got released
            if (!hand.GetStandardInteractionButton())
            {
                StartCoroutine(LateDetach(hand));
            }

            if (attachEaseIn)
            {
                var 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;
                }
            }
        }
コード例 #4
0
        //-------------------------------------------------
        protected virtual void HandAttachedUpdate(Hand 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;
                }
            }

            if (hand.IsGrabEnding(this.gameObject))
            {
                hand.DetachObject(gameObject, restoreOriginalParent);

                // Uncomment to 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 ) );
            }
        }
コード例 #5
0
        //-------------------------------------------------
        private void HandAttachedUpdate(Hand hand)
        {
            //Trigger got released
            if (!hand.buttonsListener.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;
                }
            }
        }
コード例 #6
0
        //-------------------------------------------------
        void Update()
        {
            if (renderModel != null && renderModel.gameObject.activeInHierarchy && flashingRenderers.Count > 0)
            {
                Color baseColor = usingMaterial.GetColor(colorID);

                float flash = (Time.realtimeSinceStartup - startTime) * Mathf.PI * 2.0f;
                flash = Mathf.Cos(flash);
                flash = Util.RemapNumberClamped(flash, -1.0f, 1.0f, 0.0f, 1.0f);

                float ticks = (Time.realtimeSinceStartup - startTime);
                if (ticks - tickCount > 1.0f)
                {
                    tickCount += 1.0f;
                    hapticFlash.Execute(0, 0.005f, 0.005f, 1, inputSource);
                }

                for (int i = 0; i < flashingRenderers.Count; i++)
                {
                    Renderer r = flashingRenderers[i];
                    r.material.SetColor(colorID, Color.Lerp(baseColor, flashColor, flash));
                }

                if (initialized)
                {
                    foreach (var hintInfo in actionHintInfos)
                    {
                        if (hintInfo.Value.textHintActive)
                        {
                            UpdateTextHint(hintInfo.Value);
                        }
                    }
                }
            }
        }
コード例 #7
0
        // Token: 0x06002076 RID: 8310 RVA: 0x000A03E8 File Offset: 0x0009E5E8
        private void UpdateHovering()
        {
            if (this.noSteamVRFallbackCamera == null && this.controller == null)
            {
                return;
            }
            if (this.hoverLocked)
            {
                return;
            }
            if (this.applicationLostFocusObject.activeSelf)
            {
                return;
            }
            float        num = float.MaxValue;
            Interactable hoveringInteractable = null;
            float        x    = this.playerInstance.transform.lossyScale.x;
            float        num2 = this.hoverSphereRadius * x;
            float        num3 = Util.RemapNumberClamped(Mathf.Abs(base.transform.position.y - this.playerInstance.trackingOriginTransform.position.y), 0f, 0.5f * x, 5f, 1f) * x;

            for (int i = 0; i < this.overlappingColliders.Length; i++)
            {
                this.overlappingColliders[i] = null;
            }
            Physics.OverlapBoxNonAlloc(this.hoverSphereTransform.position - new Vector3(0f, num2 * num3 - num2, 0f), new Vector3(num2, num2 * num3 * 2f, num2), this.overlappingColliders, Quaternion.identity, this.hoverLayerMask.value);
            int num4 = 0;

            Collider[] array = this.overlappingColliders;
            for (int j = 0; j < array.Length; j++)
            {
                Collider collider = array[j];
                if (!(collider == null))
                {
                    Interactable contacting = collider.GetComponentInParent <Interactable>();
                    if (!(contacting == null))
                    {
                        IgnoreHovering component = collider.GetComponent <IgnoreHovering>();
                        if ((!(component != null) || (!(component.onlyIgnoreHand == null) && !(component.onlyIgnoreHand == this))) && this.attachedObjects.FindIndex((Hand.AttachedObject l) => l.attachedObject == contacting.gameObject) == -1 && (!this.otherHand || !(this.otherHand.hoveringInteractable == contacting)))
                        {
                            float num5 = Vector3.Distance(contacting.transform.position, this.hoverSphereTransform.position);
                            if (num5 < num)
                            {
                                num = num5;
                                hoveringInteractable = contacting;
                            }
                            num4++;
                        }
                    }
                }
            }
            this.hoveringInteractable = hoveringInteractable;
            if (num4 > 0 && num4 != this.prevOverlappingColliders)
            {
                this.prevOverlappingColliders = num4;
                this.HandDebugLog("Found " + num4 + " overlapping colliders.");
            }
        }
コード例 #8
0
ファイル: LinearBlendshape.cs プロジェクト: Smoothstep/VRChat
        // Token: 0x06005CD7 RID: 23767 RVA: 0x00206AD8 File Offset: 0x00204ED8
        private void Update()
        {
            float value = this.linearMapping.value;

            if (value != this.lastValue)
            {
                float value2 = Util.RemapNumberClamped(value, 0f, 1f, 1f, 100f);
                this.skinnedMesh.SetBlendShapeWeight(0, value2);
            }
            this.lastValue = value;
        }
コード例 #9
0
        //-------------------------------------------------
        private void Update()
        {
            var value = linearMapping.value;

            //No need to set the blend if our value hasn't changed.
            if (value != lastValue)
            {
                var blendValue = Util.RemapNumberClamped(value, 0f, 1f, 1f, 100f);
                skinnedMesh.SetBlendShapeWeight(0, blendValue);
            }

            lastValue = value;
        }
コード例 #10
0
ファイル: Longbow.cs プロジェクト: Smoothstep/VRChat
        // Token: 0x06005DD5 RID: 24021 RVA: 0x0020D780 File Offset: 0x0020BB80
        private IEnumerator ResetDrawAnim()
        {
            float startTime = Time.time;
            float startLerp = this.drawTension;

            while (Time.time < startTime + 0.02f)
            {
                float lerp = Util.RemapNumberClamped(Time.time, startTime, startTime + 0.02f, startLerp, 0f);
                this.bowDrawLinearMapping.value = lerp;
                yield return(null);
            }
            this.bowDrawLinearMapping.value = 0f;
            yield break;
        }
コード例 #11
0
        //-------------------------------------------------
        private IEnumerator HapticPulses(SteamVR_Controller.Device controller, float flMagnitude, int nCount)
        {
            if (controller != null)
            {
                int nRangeMax = (int)Util.RemapNumberClamped(flMagnitude, 0.0f, 1.0f, 100.0f, 900.0f);
                nCount = Mathf.Clamp(nCount, 1, 10);

                for (ushort i = 0; i < nCount; ++i)
                {
                    ushort duration = (ushort)Random.Range(100, nRangeMax);
                    controller.TriggerHapticPulse(duration);
                    yield return(new WaitForSeconds(.01f));
                }
            }
        }
コード例 #12
0
ファイル: CircularDrive.cs プロジェクト: DevZhav/The-Forest
        private IEnumerator HapticPulses(SteamVR_Controller.Device controller, float flMagnitude, int nCount)
        {
            if (controller != null)
            {
                int nRangeMax = (int)Util.RemapNumberClamped(flMagnitude, 0f, 1f, 100f, 900f);
                nCount = Mathf.Clamp(nCount, 1, 10);
                ushort i = 0;
                while ((int)i < nCount)
                {
                    ushort duration = (ushort)UnityEngine.Random.Range(100, nRangeMax);
                    controller.TriggerHapticPulse(duration, EVRButtonId.k_EButton_Axis0);
                    yield return(new WaitForSeconds(0.01f));

                    i += 1;
                }
            }
            yield break;
        }
コード例 #13
0
        //-------------------------------------------------
        private IEnumerator ResetDrawAnim()
        {
            float startTime = Time.time;
            float startLerp = drawTension;

            while (Time.time < (startTime + 0.02f))
            {
                float lerp = Util.RemapNumberClamped(Time.time, startTime, startTime + 0.02f, startLerp, 0f);
                //this.bowDrawLinearMapping.value = lerp;
                longBowAni.Play(0, 0, lerp);
                yield return(null);
            }

            //this.bowDrawLinearMapping.value = 0;
            longBowAni.Play(0, 0, 0);

            yield break;
        }
コード例 #14
0
        private IEnumerator FallDown()
        {
            if (this.baseTransform)
            {
                Quaternion startingRot = this.baseTransform.rotation;
                float      startTime   = Time.time;
                float      rotLerp     = 0f;
                while (rotLerp < 1f)
                {
                    rotLerp = Util.RemapNumberClamped(Time.time, startTime, startTime + this.fallTime, 0f, 1f);
                    this.baseTransform.rotation = Quaternion.Lerp(startingRot, this.fallenDownTransform.rotation, rotLerp);
                    yield return(null);
                }
            }
            yield return(null);

            yield break;
        }
コード例 #15
0
        private IEnumerator ResetDrawAnim()
        {
            float startTime = Time.time;
            float startLerp = this.drawTension;

            while (Time.time < startTime + 0.02f)
            {
                float lerp = Util.RemapNumberClamped(Time.time, startTime, startTime + 0.02f, startLerp, 0f);
                this.bowDrawLinearMapping.value = lerp;
                yield return(null);
            }
            if (ForestVR.Enabled)
            {
                LocalPlayer.Animator.SetBool("bowFireBool", false);
            }
            this.bowDrawLinearMapping.value = 0f;
            yield break;
        }
コード例 #16
0
ファイル: CircularDrive.cs プロジェクト: Fireez30/ARVR-Game
        //-------------------------------------------------
        private IEnumerator HapticPulses(Hand hand, float flMagnitude, int nCount)
        {
            if (hand != null)
            {
                int nRangeMax = (int)Util.RemapNumberClamped(flMagnitude, 0.0f, 1.0f, 100.0f, 900.0f);
                nCount = Mathf.Clamp(nCount, 1, 10);

                //float hapticDuration = nRangeMax * nCount;

                //hand.TriggerHapticPulse(hapticDuration, nRangeMax, flMagnitude);

                for (ushort i = 0; i < nCount; ++i)
                {
                    ushort duration = (ushort)Random.Range(100, nRangeMax);
                    hand.TriggerHapticPulse(duration);
                    yield return(new WaitForSeconds(.01f));
                }
            }
        }
コード例 #17
0
        //-------------------------------------------------
        private IEnumerator FallDown()
        {
            if (baseTransform)
            {
                var startingRot = baseTransform.rotation;

                var startTime = Time.time;
                var rotLerp   = 0f;

                while (rotLerp < 1)
                {
                    rotLerp = Util.RemapNumberClamped(Time.time, startTime, startTime + fallTime, 0f, 1f);
                    baseTransform.rotation = Quaternion.Lerp(startingRot, fallenDownTransform.rotation, rotLerp);
                    yield return(null);
                }
            }

            yield return(null);
        }
コード例 #18
0
ファイル: Throwable.cs プロジェクト: DevZhav/The-Forest
 private void HandAttachedUpdate(Hand hand)
 {
     if (!hand.GetStandardInteractionButton())
     {
         base.StartCoroutine(this.LateDetach(hand));
     }
     if (this.attachEaseIn)
     {
         float num = Util.RemapNumberClamped(Time.time, this.attachTime, this.attachTime + this.snapAttachEaseInTime, 0f, 1f);
         if (num < 1f)
         {
             num = this.snapAttachEaseInCurve.Evaluate(num);
             base.transform.position = Vector3.Lerp(this.attachPosition, this.attachEaseInTransform.position, num);
             base.transform.rotation = Quaternion.Lerp(this.attachRotation, this.attachEaseInTransform.rotation, num);
         }
         else if (!this.snapAttachEaseInCompleted)
         {
             base.gameObject.SendMessage("OnThrowableAttachEaseInCompleted", hand, SendMessageOptions.DontRequireReceiver);
             this.snapAttachEaseInCompleted = true;
         }
     }
 }
コード例 #19
0
        //-------------------------------------------------
        void Update()
        {
            if (renderModel != null && renderModel.gameObject.activeInHierarchy && flashingRenderers.Count > 0)
            {
                Color baseColor = controllerMaterial.GetColor(colorID);

                float flash = (Time.realtimeSinceStartup - startTime) * Mathf.PI * 2.0f;
                flash = Mathf.Cos(flash);
                flash = Util.RemapNumberClamped(flash, -1.0f, 1.0f, 0.0f, 1.0f);

                float ticks = (Time.realtimeSinceStartup - startTime);
                if (ticks - tickCount > 1.0f)
                {
                    tickCount += 1.0f;
                    SteamVR_Controller.Device device = SteamVR_Controller.Input((int)renderModel.index);
                    if (device != null)
                    {
                        device.TriggerHapticPulse();
                    }
                }

                for (int i = 0; i < flashingRenderers.Count; i++)
                {
                    Renderer r = flashingRenderers[i];
                    r.material.SetColor(colorID, Color.Lerp(baseColor, flashColor, flash));
                }

                if (initialized)
                {
                    foreach (var hintInfo in buttonHintInfos)
                    {
                        if (hintInfo.Value.textHintActive)
                        {
                            UpdateTextHint(hintInfo.Value);
                        }
                    }
                }
            }
        }
コード例 #20
0
        //-------------------------------------------------
        private void HandAttachedUpdate(Hand hand)
        {
            if (hand.otherHand.controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Grip))
            {
                // 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;
                }
            }

            //currentAcceleration = velocityEstimator.GetAccelerationEstimate();
            currentVelocity = velocityEstimator.GetVelocityEstimate();
            //Debug.Log(rb.velocity);
            if (currentVelocity.magnitude > flickThreshold)
            {
                GetComponent <GlobMaker>().createProjectile(currentVelocity.magnitude, true); //true means with noise
            }
        }
コード例 #21
0
        private void UpdateTextHint(ControllerButtonHints.ButtonHintInfo hintInfo)
        {
            Transform  hmdTransform = this.player.hmdTransform;
            Vector3    forward      = hmdTransform.position - hintInfo.canvasOffset.position;
            Quaternion a            = Quaternion.LookRotation(forward, Vector3.up);
            Quaternion b            = Quaternion.LookRotation(forward, hmdTransform.up);
            float      t;

            if (hmdTransform.forward.y > 0f)
            {
                t = Util.RemapNumberClamped(hmdTransform.forward.y, 0.6f, 0.4f, 1f, 0f);
            }
            else
            {
                t = Util.RemapNumberClamped(hmdTransform.forward.y, -0.8f, -0.6f, 1f, 0f);
            }
            hintInfo.canvasOffset.rotation = Quaternion.Slerp(a, b, t);
            Transform transform = hintInfo.line.transform;

            hintInfo.line.useWorldSpace = false;
            hintInfo.line.SetPosition(0, transform.InverseTransformPoint(hintInfo.textStartAnchor.position));
            hintInfo.line.SetPosition(1, transform.InverseTransformPoint(hintInfo.textEndAnchor.position));
        }
コード例 #22
0
 void SetReticleActive(bool pointerAtBadAngle, Vector3 at_position, bool hit_marker)
 {
     if (hit_marker)
     {
         destinationReticleTransform.gameObject.SetActive(false);
         invalidReticleTransform.gameObject.SetActive(false);
     }
     else
     {
         bool show_good_reticle = !pointerAtBadAngle;                 //and area not invalid
         destinationReticleTransform.gameObject.SetActive(show_good_reticle);
         invalidReticleTransform.gameObject.SetActive(!show_good_reticle);
         if (!show_good_reticle)
         {
             //Scale the invalid reticle based on the distance from the player
             float distanceFromPlayer         = Vector3.Distance(at_position, player.hmdTransform.position);
             float invalidReticleCurrentScale = Util.RemapNumberClamped(distanceFromPlayer, invalidReticleMinScaleDistance, invalidReticleMaxScaleDistance, invalidReticleMinScale, invalidReticleMaxScale);
             invalidReticleTransform.transform.localScale = Vector3.one * invalidReticleCurrentScale;
         }
         destinationReticleTransform.position  = at_position;
         invalidReticleTransform.position      = at_position;
         reticleAudioSource.transform.position = at_position;
     }
 }
コード例 #23
0
        //-------------------------------------------------
        private void UpdateHovering()
        {
            if ((noSteamVRFallbackCamera == null) && (controller == null))
            {
                return;
            }

            if (hoverLocked)
            {
                return;
            }

            if (applicationLostFocusObject.activeSelf)
            {
                return;
            }

            float        closestDistance     = float.MaxValue;
            Interactable closestInteractable = null;

            // Pick the closest hovering
            float flHoverRadiusScale   = playerInstance.transform.lossyScale.x;
            float flScaledSphereRadius = hoverSphereRadius * flHoverRadiusScale;

            // if we're close to the floor, increase the radius to make things easier to pick up
            float handDiff = Mathf.Abs(transform.position.y - playerInstance.trackingOriginTransform.position.y);
            float boxMult  = Util.RemapNumberClamped(handDiff, 0.0f, 0.5f * flHoverRadiusScale, 5.0f, 1.0f) * flHoverRadiusScale;

            // null out old vals
            for (int i = 0; i < overlappingColliders.Length; ++i)
            {
                overlappingColliders[i] = null;
            }

            Physics.OverlapBoxNonAlloc(
                hoverSphereTransform.position - new Vector3(0, flScaledSphereRadius * boxMult - flScaledSphereRadius, 0),
                new Vector3(flScaledSphereRadius, flScaledSphereRadius * boxMult * 2.0f, flScaledSphereRadius),
                overlappingColliders,
                Quaternion.identity,
                hoverLayerMask.value
                );

            // DebugVar
            int iActualColliderCount = 0;

            foreach (Collider collider in overlappingColliders)
            {
                if (collider == null)
                {
                    continue;
                }

                Interactable contacting = collider.GetComponentInParent <Interactable>();

                // Yeah, it's null, skip
                if (contacting == null)
                {
                    continue;
                }

                // Ignore this collider for hovering
                IgnoreHovering ignore = collider.GetComponent <IgnoreHovering>();
                if (ignore != null)
                {
                    if (ignore.onlyIgnoreHand == null || ignore.onlyIgnoreHand == this)
                    {
                        continue;
                    }
                }

                // Can't hover over the object if it's attached
                if (attachedObjects.FindIndex(l => l.attachedObject == contacting.gameObject) != -1)
                {
                    continue;
                }

                // Occupied by another hand, so we can't touch it
                if (otherHand && otherHand.hoveringInteractable == contacting)
                {
                    continue;
                }

                // Best candidate so far...
                float distance = Vector3.Distance(contacting.transform.position, hoverSphereTransform.position);
                if (distance < closestDistance)
                {
                    closestDistance     = distance;
                    closestInteractable = contacting;
                }
                iActualColliderCount++;
            }

            // Hover on this one
            hoveringInteractable = closestInteractable;

            if (iActualColliderCount > 0 && iActualColliderCount != prevOverlappingColliders)
            {
                prevOverlappingColliders = iActualColliderCount;
                HandDebugLog("Found " + iActualColliderCount + " overlapping colliders.");
            }
        }
コード例 #24
0
ファイル: ArrowCopy.cs プロジェクト: nlehnert1/Roll-A-Ball2
        //-------------------------------------------------
        private void StickInTarget(Collision collision, bool bSkipRayCast)
        {
            Vector3 prevForward = prevRotation * Vector3.forward;

            // Only stick in target if the collider is front of the arrow head
            if (!bSkipRayCast)
            {
                RaycastHit[] hitInfo;
                hitInfo = Physics.RaycastAll(prevHeadPosition - prevVelocity * Time.deltaTime, prevForward, prevVelocity.magnitude * Time.deltaTime * 2.0f);
                bool properHit = false;
                for (int i = 0; i < hitInfo.Length; ++i)
                {
                    RaycastHit hit = hitInfo[i];

                    if (hit.collider == collision.collider)
                    {
                        properHit = true;
                        break;
                    }
                }

                if (!properHit)
                {
                    return;
                }
            }

            Destroy(glintParticle);

            inFlight = false;

            SetCollisionMode(CollisionDetectionMode.Discrete, true);

            shaftRB.velocity        = Vector3.zero;
            shaftRB.angularVelocity = Vector3.zero;
            shaftRB.isKinematic     = true;
            shaftRB.useGravity      = false;
            shaftRB.transform.GetComponent <BoxCollider>().enabled = false;

            arrowHeadRB.velocity        = Vector3.zero;
            arrowHeadRB.angularVelocity = Vector3.zero;
            arrowHeadRB.isKinematic     = true;
            arrowHeadRB.useGravity      = false;
            arrowHeadRB.transform.GetComponent <BoxCollider>().enabled = false;

            hitTargetSound.Play();


            // If the hit item has a parent, dock an empty object to that
            // this fixes an issue with scaling hierarchy. I suspect this is not sustainable for a large object / scaling hierarchy.
            scaleParentObject = new GameObject("Arrow Scale Parent");
            Transform parentTransform = collision.collider.transform;

            // Don't do this for weebles because of how it has a fixed joint
            ExplosionWobble wobble = collision.collider.gameObject.GetComponent <ExplosionWobble>();

            if (!wobble)
            {
                if (parentTransform.parent)
                {
                    parentTransform = parentTransform.parent;
                }
            }

            scaleParentObject.transform.parent = parentTransform;

            // Move the arrow to the place on the target collider we were expecting to hit prior to the impact itself knocking it around
            transform.parent   = scaleParentObject.transform;
            transform.rotation = prevRotation;
            transform.position = prevPosition;
            transform.position = collision.contacts[0].point - transform.forward * (0.75f - (Util.RemapNumberClamped(prevVelocity.magnitude, 0f, 10f, 0.0f, 0.1f) + Random.Range(0.0f, 0.05f)));
        }
コード例 #25
0
ファイル: CircularDrive.cs プロジェクト: Fireez30/ARVR-Game
        //-------------------------------------------------
        // Computes the angle to rotate the game object based on the change in the transform
        //-------------------------------------------------
        private void ComputeAngle(Hand hand)
        {
            Vector3 toHandProjected = ComputeToTransformProjected(hand.hoverSphereTransform);

            if (!toHandProjected.Equals(lastHandProjected))
            {
                float absAngleDelta = Vector3.Angle(lastHandProjected, toHandProjected);

                if (absAngleDelta > 0.0f)
                {
                    if (frozen)
                    {
                        float frozenSqDist = (hand.hoverSphereTransform.position - frozenHandWorldPos).sqrMagnitude;
                        if (frozenSqDist > frozenSqDistanceMinMaxThreshold.x)
                        {
                            outAngle = frozenAngle + Random.Range(-1.0f, 1.0f);

                            float magnitude = Util.RemapNumberClamped(frozenSqDist, frozenSqDistanceMinMaxThreshold.x, frozenSqDistanceMinMaxThreshold.y, 0.0f, 1.0f);
                            if (magnitude > 0)
                            {
                                StartCoroutine(HapticPulses(hand, magnitude, 10));
                            }
                            else
                            {
                                StartCoroutine(HapticPulses(hand, 0.5f, 10));
                            }

                            if (frozenSqDist >= frozenSqDistanceMinMaxThreshold.y)
                            {
                                onFrozenDistanceThreshold.Invoke();
                            }
                        }
                    }
                    else
                    {
                        Vector3 cross = Vector3.Cross(lastHandProjected, toHandProjected).normalized;
                        float   dot   = Vector3.Dot(worldPlaneNormal, cross);

                        float signedAngleDelta = absAngleDelta;

                        if (dot < 0.0f)
                        {
                            signedAngleDelta = -signedAngleDelta;
                        }

                        if (limited)
                        {
                            float angleTmp = Mathf.Clamp(outAngle + signedAngleDelta, minAngle, maxAngle);

                            if (outAngle == minAngle)
                            {
                                if (angleTmp > minAngle && absAngleDelta < minMaxAngularThreshold)
                                {
                                    outAngle          = angleTmp;
                                    lastHandProjected = toHandProjected;
                                }
                            }
                            else if (outAngle == maxAngle)
                            {
                                if (angleTmp < maxAngle && absAngleDelta < minMaxAngularThreshold)
                                {
                                    outAngle          = angleTmp;
                                    lastHandProjected = toHandProjected;
                                }
                            }
                            else if (angleTmp == minAngle)
                            {
                                outAngle          = angleTmp;
                                lastHandProjected = toHandProjected;
                                onMinAngle.Invoke();
                                if (freezeOnMin)
                                {
                                    Freeze(hand);
                                }
                            }
                            else if (angleTmp == maxAngle)
                            {
                                outAngle          = angleTmp;
                                lastHandProjected = toHandProjected;
                                onMaxAngle.Invoke();
                                if (freezeOnMax)
                                {
                                    Freeze(hand);
                                }
                            }
                            else
                            {
                                outAngle          = angleTmp;
                                lastHandProjected = toHandProjected;
                            }
                        }
                        else
                        {
                            outAngle         += signedAngleDelta;
                            lastHandProjected = toHandProjected;
                        }
                    }
                }
            }
        }
コード例 #26
0
ファイル: Arrow.cs プロジェクト: K07H/The-Forest
        private void StickInTarget(Collision collision, bool bSkipRayCast)
        {
            Vector3 direction = this.prevRotation * Vector3.forward;

            if (!bSkipRayCast)
            {
                RaycastHit[] array = Physics.RaycastAll(this.prevHeadPosition - this.prevVelocity * Time.deltaTime, direction, this.prevVelocity.magnitude * Time.deltaTime * 2f);
                bool         flag  = false;
                foreach (RaycastHit raycastHit in array)
                {
                    if (raycastHit.collider == collision.collider)
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    return;
                }
            }
            UnityEngine.Object.Destroy(this.glintParticle);
            this.inFlight                = false;
            this.shaftRB.velocity        = Vector3.zero;
            this.shaftRB.angularVelocity = Vector3.zero;
            this.shaftRB.isKinematic     = true;
            this.shaftRB.useGravity      = false;
            this.shaftRB.transform.GetComponent <BoxCollider>().enabled = false;
            this.arrowHeadRB.velocity        = Vector3.zero;
            this.arrowHeadRB.angularVelocity = Vector3.zero;
            this.arrowHeadRB.isKinematic     = true;
            this.arrowHeadRB.useGravity      = false;
            this.arrowHeadRB.transform.GetComponent <BoxCollider>().enabled = false;
            this.hitTargetSound.Play();
            this.scaleParentObject = new GameObject("Arrow Scale Parent");
            Transform       transform = collision.collider.transform;
            ExplosionWobble component = collision.collider.gameObject.GetComponent <ExplosionWobble>();

            if (!component && transform.parent)
            {
                transform = transform.parent;
            }
            this.scaleParentObject.transform.parent = transform;
            base.transform.parent   = this.scaleParentObject.transform;
            base.transform.rotation = this.prevRotation;
            base.transform.position = this.prevPosition;
            base.transform.position = collision.contacts[0].point - base.transform.forward * (0.75f - (Util.RemapNumberClamped(this.prevVelocity.magnitude, 0f, 10f, 0f, 0.1f) + UnityEngine.Random.Range(0f, 0.05f)));
        }
コード例 #27
0
        //-------------------------------------------------
        private void UpdatePointer()
        {
            Vector3 pointerStart = pointerStartTransform.position;
            Vector3 pointerEnd;
            Vector3 pointerDir          = pointerStartTransform.forward;
            bool    hitSomething        = false;
            bool    showPlayAreaPreview = false;
            Vector3 playerFeetOffset    = player.trackingOriginTransform.position - player.feetPositionGuess;

            Vector3 arcVelocity = pointerDir * arcDistance;

            TeleportMarkerBase hitTeleportMarker = null;

            //Check pointer angle
            float dotUp             = Vector3.Dot(pointerDir, Vector3.up);
            float dotForward        = Vector3.Dot(pointerDir, player.hmdTransform.forward);
            bool  pointerAtBadAngle = false;

            if ((dotForward > 0 && dotUp > 0.75f) || (dotForward < 0.0f && dotUp > 0.5f))
            {
                pointerAtBadAngle = true;
            }

            //Trace to see if the pointer hit anything
            RaycastHit hitInfo;

            teleportArc.SetArcData(pointerStart, arcVelocity, true, pointerAtBadAngle);
            if (teleportArc.DrawArc(out hitInfo))
            {
                hitSomething      = true;
                hitTeleportMarker = hitInfo.collider.GetComponentInParent <TeleportMarkerBase>();
            }

            if (pointerAtBadAngle)
            {
                hitTeleportMarker = null;
            }

            HighlightSelected(hitTeleportMarker);

            if (hitTeleportMarker != null)               //Hit a teleport marker
            {
                if (hitTeleportMarker.locked)
                {
                    teleportArc.SetColor(pointerLockedColor);
#if (UNITY_5_4)
                    pointerLineRenderer.SetColors(pointerLockedColor, pointerLockedColor);
#else
                    pointerLineRenderer.startColor = pointerLockedColor;
                    pointerLineRenderer.endColor   = pointerLockedColor;
#endif
                    destinationReticleTransform.gameObject.SetActive(false);
                }
                else
                {
                    teleportArc.SetColor(pointerValidColor);
#if (UNITY_5_4)
                    pointerLineRenderer.SetColors(pointerValidColor, pointerValidColor);
#else
                    pointerLineRenderer.startColor = pointerValidColor;
                    pointerLineRenderer.endColor   = pointerValidColor;
#endif
                    destinationReticleTransform.gameObject.SetActive(hitTeleportMarker.showReticle);
                }

                offsetReticleTransform.gameObject.SetActive(true);

                invalidReticleTransform.gameObject.SetActive(false);

                pointedAtTeleportMarker = hitTeleportMarker;
                pointedAtPosition       = hitInfo.point;

                if (showPlayAreaMarker)
                {
                    //Show the play area marker if this is a teleport area
                    TeleportArea teleportArea = pointedAtTeleportMarker as TeleportArea;
                    if (teleportArea != null && !teleportArea.locked && playAreaPreviewTransform != null)
                    {
                        Vector3 offsetToUse = playerFeetOffset;

                        //Adjust the actual offset to prevent the play area marker from moving too much
                        if (!movedFeetFarEnough)
                        {
                            float distanceFromStartingOffset = Vector3.Distance(playerFeetOffset, startingFeetOffset);
                            if (distanceFromStartingOffset < 0.1f)
                            {
                                offsetToUse = startingFeetOffset;
                            }
                            else if (distanceFromStartingOffset < 0.4f)
                            {
                                offsetToUse = Vector3.Lerp(startingFeetOffset, playerFeetOffset, (distanceFromStartingOffset - 0.1f) / 0.3f);
                            }
                            else
                            {
                                movedFeetFarEnough = true;
                            }
                        }

                        playAreaPreviewTransform.position = pointedAtPosition + offsetToUse;

                        showPlayAreaPreview = true;
                    }
                }

                pointerEnd = hitInfo.point;
            }
            else             //Hit neither
            {
                destinationReticleTransform.gameObject.SetActive(false);
                offsetReticleTransform.gameObject.SetActive(false);

                teleportArc.SetColor(pointerInvalidColor);
#if (UNITY_5_4)
                pointerLineRenderer.SetColors(pointerInvalidColor, pointerInvalidColor);
#else
                pointerLineRenderer.startColor = pointerInvalidColor;
                pointerLineRenderer.endColor   = pointerInvalidColor;
#endif
                invalidReticleTransform.gameObject.SetActive(!pointerAtBadAngle);

                //Orient the invalid reticle to the normal of the trace hit point
                Vector3 normalToUse = hitInfo.normal;
                float   angle       = Vector3.Angle(hitInfo.normal, Vector3.up);
                if (angle < 15.0f)
                {
                    normalToUse = Vector3.up;
                }
                invalidReticleTargetRotation     = Quaternion.FromToRotation(Vector3.up, normalToUse);
                invalidReticleTransform.rotation = Quaternion.Slerp(invalidReticleTransform.rotation, invalidReticleTargetRotation, 0.1f);

                //Scale the invalid reticle based on the distance from the player
                float distanceFromPlayer         = Vector3.Distance(hitInfo.point, player.hmdTransform.position);
                float invalidReticleCurrentScale = Util.RemapNumberClamped(distanceFromPlayer, invalidReticleMinScaleDistance, invalidReticleMaxScaleDistance, invalidReticleMinScale, invalidReticleMaxScale);
                invalidReticleScale.x = invalidReticleCurrentScale;
                invalidReticleScale.y = invalidReticleCurrentScale;
                invalidReticleScale.z = invalidReticleCurrentScale;
                invalidReticleTransform.transform.localScale = invalidReticleScale;

                pointedAtTeleportMarker = null;

                if (hitSomething)
                {
                    pointerEnd = hitInfo.point;
                }
                else
                {
                    pointerEnd = teleportArc.GetArcPositionAtTime(teleportArc.arcDuration);
                }

                //Debug floor
                if (debugFloor)
                {
                    floorDebugSphere.gameObject.SetActive(false);
                    floorDebugLine.gameObject.SetActive(false);
                }
            }

            if (playAreaPreviewTransform != null)
            {
                playAreaPreviewTransform.gameObject.SetActive(showPlayAreaPreview);
            }

            if (!showOffsetReticle)
            {
                offsetReticleTransform.gameObject.SetActive(false);
            }

            destinationReticleTransform.position = pointedAtPosition;
            invalidReticleTransform.position     = pointerEnd;
            onActivateObjectTransform.position   = pointerEnd;
            onDeactivateObjectTransform.position = pointerEnd;
            offsetReticleTransform.position      = pointerEnd - playerFeetOffset;

            reticleAudioSource.transform.position = pointedAtPosition;

            pointerLineRenderer.SetPosition(0, pointerStart);
            pointerLineRenderer.SetPosition(1, pointerEnd);
        }
コード例 #28
0
        //-------------------------------------------------
        private void HandAttachedUpdate(Hand hand)
        {
            // Reset transform since we cheated it right after getting poses on previous frame
            //transform.localPosition = Vector3.zero;
            //transform.localRotation = Quaternion.identity;

            // Update handedness guess
            EvaluateHandedness();

            if (nocked)
            {
                Vector3 nockToarrowHand = (arrowHand.arrowNockTransform.parent.position - nockRestTransform.position); // Vector from bow nock transform to arrowhand nock transform - used to align bow when drawing

                // Align bow
                // Time lerp value used for ramping into drawn bow orientation
                float lerp = Util.RemapNumberClamped(Time.time, nockLerpStartTime, (nockLerpStartTime + lerpDuration), 0f, 1f);

                float pullLerp = Util.RemapNumberClamped(nockToarrowHand.magnitude, minPull, maxPull, 0f, 1f); // Normalized current state of bow draw 0 - 1

                Vector3 arrowNockTransformToHeadset = ((Player.instance.hmdTransform.position + (Vector3.down * 0.05f)) - arrowHand.arrowNockTransform.parent.position).normalized;
                Vector3 arrowHandPosition           = (arrowHand.arrowNockTransform.parent.position + ((arrowNockTransformToHeadset * drawOffset) * pullLerp)); // Use this line to lerp arrowHand nock position
                                                                                                                                                                //Vector3 arrowHandPosition = arrowHand.arrowNockTransform.position; // Use this line if we don't want to lerp arrowHand nock position

                Vector3 pivotToString      = (arrowHandPosition - pivotTransform.position).normalized;
                Vector3 pivotToLowerHandle = (handleTransform.position - pivotTransform.position).normalized;
                bowLeftVector           = -Vector3.Cross(pivotToLowerHandle, pivotToString);
                pivotTransform.rotation = Quaternion.Lerp(nockLerpStartRotation, Quaternion.LookRotation(pivotToString, bowLeftVector), lerp);

                // Move nock position
                if (Vector3.Dot(nockToarrowHand, -nockTransform.forward) > 0)
                {
                    float distanceToarrowHand = nockToarrowHand.magnitude * lerp;

                    nockTransform.localPosition = new Vector3(0f, 0f, Mathf.Clamp(-distanceToarrowHand, -maxPull, 0f));

                    nockDistanceTravelled = -nockTransform.localPosition.z;

                    arrowVelocity = Util.RemapNumber(nockDistanceTravelled, minPull, maxPull, arrowMinVelocity, arrowMaxVelocity);

                    drawTension = Util.RemapNumberClamped(nockDistanceTravelled, 0, maxPull, 0f, 1f);

                    this.bowDrawLinearMapping.value = drawTension; // Send drawTension value to LinearMapping script, which drives the bow draw animation

                    if (nockDistanceTravelled > minPull)
                    {
                        pulled = true;
                    }
                    else
                    {
                        pulled = false;
                    }

                    if ((nockDistanceTravelled > (lastTickDistance + hapticDistanceThreshold)) || nockDistanceTravelled < (lastTickDistance - hapticDistanceThreshold))
                    {
                        ushort hapticStrength = (ushort)Util.RemapNumber(nockDistanceTravelled, 0, maxPull, bowPullPulseStrengthLow, bowPullPulseStrengthHigh);
                        hand.TriggerHapticPulse(hapticStrength);
                        hand.otherHand.TriggerHapticPulse(hapticStrength);

                        drawSound.PlayBowTensionClicks(drawTension);

                        lastTickDistance = nockDistanceTravelled;
                    }

                    if (nockDistanceTravelled >= maxPull)
                    {
                        if (Time.time > nextStrainTick)
                        {
                            hand.TriggerHapticPulse(400);
                            hand.otherHand.TriggerHapticPulse(400);

                            drawSound.PlayBowTensionClicks(drawTension);

                            nextStrainTick = Time.time + Random.Range(minStrainTickTime, maxStrainTickTime);
                        }
                    }
                }
                else
                {
                    nockTransform.localPosition = new Vector3(0f, 0f, 0f);

                    this.bowDrawLinearMapping.value = 0f;
                }
            }
            else
            {
                if (lerpBackToZeroRotation)
                {
                    float lerp = Util.RemapNumber(Time.time, lerpStartTime, lerpStartTime + lerpDuration, 0, 1);

                    pivotTransform.localRotation = Quaternion.Lerp(lerpStartRotation, Quaternion.identity, lerp);

                    if (lerp >= 1)
                    {
                        lerpBackToZeroRotation = false;
                    }
                }
            }
        }
コード例 #29
0
ファイル: CircularDrive.cs プロジェクト: DevZhav/The-Forest
        private void ComputeAngle(Hand hand)
        {
            Vector3 vector = this.ComputeToTransformProjected(hand.hoverSphereTransform);

            if (!vector.Equals(this.lastHandProjected))
            {
                float num = Vector3.Angle(this.lastHandProjected, vector);
                if (num > 0f)
                {
                    if (this.frozen)
                    {
                        float sqrMagnitude = (hand.hoverSphereTransform.position - this.frozenHandWorldPos).sqrMagnitude;
                        if (sqrMagnitude > this.frozenSqDistanceMinMaxThreshold.x)
                        {
                            this.outAngle = this.frozenAngle + UnityEngine.Random.Range(-1f, 1f);
                            float num2 = Util.RemapNumberClamped(sqrMagnitude, this.frozenSqDistanceMinMaxThreshold.x, this.frozenSqDistanceMinMaxThreshold.y, 0f, 1f);
                            if (num2 > 0f)
                            {
                                base.StartCoroutine(this.HapticPulses(hand.controller, num2, 10));
                            }
                            else
                            {
                                base.StartCoroutine(this.HapticPulses(hand.controller, 0.5f, 10));
                            }
                            if (sqrMagnitude >= this.frozenSqDistanceMinMaxThreshold.y)
                            {
                                this.onFrozenDistanceThreshold.Invoke();
                            }
                        }
                    }
                    else
                    {
                        Vector3 normalized = Vector3.Cross(this.lastHandProjected, vector).normalized;
                        float   num3       = Vector3.Dot(this.worldPlaneNormal, normalized);
                        float   num4       = num;
                        if (num3 < 0f)
                        {
                            num4 = -num4;
                        }
                        if (this.limited)
                        {
                            float num5 = Mathf.Clamp(this.outAngle + num4, this.minAngle, this.maxAngle);
                            if (this.outAngle == this.minAngle)
                            {
                                if (num5 > this.minAngle && num < this.minMaxAngularThreshold)
                                {
                                    this.outAngle          = num5;
                                    this.lastHandProjected = vector;
                                }
                            }
                            else if (this.outAngle == this.maxAngle)
                            {
                                if (num5 < this.maxAngle && num < this.minMaxAngularThreshold)
                                {
                                    this.outAngle          = num5;
                                    this.lastHandProjected = vector;
                                }
                            }
                            else if (num5 == this.minAngle)
                            {
                                this.outAngle          = num5;
                                this.lastHandProjected = vector;
                                this.onMinAngle.Invoke();
                                if (this.freezeOnMin)
                                {
                                    this.Freeze(hand);
                                }
                            }
                            else if (num5 == this.maxAngle)
                            {
                                this.outAngle          = num5;
                                this.lastHandProjected = vector;
                                this.onMaxAngle.Invoke();
                                if (this.freezeOnMax)
                                {
                                    this.Freeze(hand);
                                }
                            }
                            else
                            {
                                this.outAngle          = num5;
                                this.lastHandProjected = vector;
                            }
                        }
                        else
                        {
                            this.outAngle         += num4;
                            this.lastHandProjected = vector;
                        }
                    }
                }
            }
        }
コード例 #30
0
ファイル: Longbow.cs プロジェクト: Smoothstep/VRChat
 // Token: 0x06005DD3 RID: 24019 RVA: 0x0020D2D8 File Offset: 0x0020B6D8
 private void HandAttachedUpdate(Hand hand)
 {
     base.transform.localPosition = Vector3.zero;
     base.transform.localRotation = Quaternion.identity;
     this.EvaluateHandedness();
     if (this.nocked)
     {
         this.deferNewPoses = true;
         Vector3 lhs         = this.arrowHand.arrowNockTransform.parent.position - this.nockRestTransform.position;
         float   num         = Util.RemapNumberClamped(Time.time, this.nockLerpStartTime, this.nockLerpStartTime + this.lerpDuration, 0f, 1f);
         float   d           = Util.RemapNumberClamped(lhs.magnitude, 0.05f, 0.5f, 0f, 1f);
         Vector3 normalized  = (Player.instance.hmdTransform.position + Vector3.down * 0.05f - this.arrowHand.arrowNockTransform.parent.position).normalized;
         Vector3 a           = this.arrowHand.arrowNockTransform.parent.position + normalized * this.drawOffset * d;
         Vector3 normalized2 = (a - this.pivotTransform.position).normalized;
         Vector3 normalized3 = (this.handleTransform.position - this.pivotTransform.position).normalized;
         this.bowLeftVector           = -Vector3.Cross(normalized3, normalized2);
         this.pivotTransform.rotation = Quaternion.Lerp(this.nockLerpStartRotation, Quaternion.LookRotation(normalized2, this.bowLeftVector), num);
         if (Vector3.Dot(lhs, -this.nockTransform.forward) > 0f)
         {
             float num2 = lhs.magnitude * num;
             this.nockTransform.localPosition = new Vector3(0f, 0f, Mathf.Clamp(-num2, -0.5f, 0f));
             this.nockDistanceTravelled       = -this.nockTransform.localPosition.z;
             this.arrowVelocity = Util.RemapNumber(this.nockDistanceTravelled, 0.05f, 0.5f, this.arrowMinVelocity, this.arrowMaxVelocity);
             this.drawTension   = Util.RemapNumberClamped(this.nockDistanceTravelled, 0f, 0.5f, 0f, 1f);
             this.bowDrawLinearMapping.value = this.drawTension;
             if (this.nockDistanceTravelled > 0.05f)
             {
                 this.pulled = true;
             }
             else
             {
                 this.pulled = false;
             }
             if (this.nockDistanceTravelled > this.lastTickDistance + this.hapticDistanceThreshold || this.nockDistanceTravelled < this.lastTickDistance - this.hapticDistanceThreshold)
             {
                 ushort durationMicroSec = (ushort)Util.RemapNumber(this.nockDistanceTravelled, 0f, 0.5f, 100f, 500f);
                 hand.controller.TriggerHapticPulse(durationMicroSec, EVRButtonId.k_EButton_Axis0);
                 hand.otherHand.controller.TriggerHapticPulse(durationMicroSec, EVRButtonId.k_EButton_Axis0);
                 this.drawSound.PlayBowTensionClicks(this.drawTension);
                 this.lastTickDistance = this.nockDistanceTravelled;
             }
             if (this.nockDistanceTravelled >= 0.5f && Time.time > this.nextStrainTick)
             {
                 hand.controller.TriggerHapticPulse(400, EVRButtonId.k_EButton_Axis0);
                 hand.otherHand.controller.TriggerHapticPulse(400, EVRButtonId.k_EButton_Axis0);
                 this.drawSound.PlayBowTensionClicks(this.drawTension);
                 this.nextStrainTick = Time.time + UnityEngine.Random.Range(this.minStrainTickTime, this.maxStrainTickTime);
             }
         }
         else
         {
             this.nockTransform.localPosition = new Vector3(0f, 0f, 0f);
             this.bowDrawLinearMapping.value  = 0f;
         }
     }
     else if (this.lerpBackToZeroRotation)
     {
         float num3 = Util.RemapNumber(Time.time, this.lerpStartTime, this.lerpStartTime + this.lerpDuration, 0f, 1f);
         this.pivotTransform.localRotation = Quaternion.Lerp(this.lerpStartRotation, Quaternion.identity, num3);
         if (num3 >= 1f)
         {
             this.lerpBackToZeroRotation = false;
         }
     }
 }