Example #1
0
        //-------------------------------------------------
        public bool IsEligibleForTeleport(Hand hand)
        {
            if (hand == null)
            {
                return(false);
            }

            if (!hand.gameObject.activeInHierarchy)
            {
                return(false);
            }

            if (hand.hoveringInteractable != null)
            {
                return(false);
            }

            if (hand.noSteamVRFallbackCamera == null)
            {
                if (hand.controller == null)
                {
                    return(false);
                }

                //Something is attached to the hand
                if (hand.currentAttachedObject != null)
                {
                    AllowTeleportWhileAttachedToHand allowTeleportWhileAttachedToHand = hand.currentAttachedObject.GetComponent <AllowTeleportWhileAttachedToHand>();

                    if (allowTeleportWhileAttachedToHand != null && allowTeleportWhileAttachedToHand.teleportAllowed == true)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Example #2
0
        //-------------------------------------------------
        private void ShowPointer(Hand newPointerHand, Hand oldPointerHand)
        {
            if (!visible)
            {
                pointedAtTeleportMarker = null;
                pointerShowStartTime    = Time.time;
                visible    = true;
                meshFading = true;

                teleportPointerObject.SetActive(false);
                teleportArc.Show();

                foreach (TeleportMarkerBase teleportMarker in teleportMarkers)
                {
                    if (teleportMarker.markerActive && teleportMarker.ShouldActivate(player.feetPositionGuess))
                    {
                        teleportMarker.gameObject.SetActive(true);
                        teleportMarker.Highlight(false);
                    }
                }

                startingFeetOffset = player.trackingOriginTransform.position - player.feetPositionGuess;
                movedFeetFarEnough = false;

                if (onDeactivateObjectTransform.gameObject.activeSelf)
                {
                    onDeactivateObjectTransform.gameObject.SetActive(false);
                }
                onActivateObjectTransform.gameObject.SetActive(true);

                loopingAudioSource.clip = pointerLoopSound;
                loopingAudioSource.loop = true;
                loopingAudioSource.Play();
                loopingAudioSource.volume = 0.0f;
            }


            if (oldPointerHand)
            {
                if (ShouldOverrideHoverLock())
                {
                    //Restore the original hovering interactable on the hand
                    if (originalHoverLockState == true)
                    {
                        oldPointerHand.HoverLock(originalHoveringInteractable);
                    }
                    else
                    {
                        oldPointerHand.HoverUnlock(null);
                    }
                }
            }

            pointerHand = newPointerHand;

            if (visible && oldPointerHand != pointerHand)
            {
                PlayAudioClip(pointerAudioSource, pointerStartSound);
            }

            if (pointerHand)
            {
                pointerStartTransform = GetPointerStartTransform(pointerHand);

                if (pointerHand.currentAttachedObject != null)
                {
                    allowTeleportWhileAttached = pointerHand.currentAttachedObject.GetComponent <AllowTeleportWhileAttachedToHand>();
                }

                //Keep track of any existing hovering interactable on the hand
                originalHoverLockState       = pointerHand.hoverLocked;
                originalHoveringInteractable = pointerHand.hoveringInteractable;

                if (ShouldOverrideHoverLock())
                {
                    pointerHand.HoverLock(null);
                }

                pointerAudioSource.transform.SetParent(pointerStartTransform);
                pointerAudioSource.transform.localPosition = Vector3.zero;

                loopingAudioSource.transform.SetParent(pointerStartTransform);
                loopingAudioSource.transform.localPosition = Vector3.zero;
            }
        }