Exemple #1
0
    private void Update()
    {
        float left  = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick).magnitude;
        float right = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick).magnitude;

        if (left != 0)
        {
            leftCast = true;
            leftTeleporter.ToggleDisplay(true);
        }
        else if (leftCast)
        {
            leftCast = false;
            leftTeleporter.Teleport();
            leftTeleporter.ToggleDisplay(false);
        }

        if (right != 0)
        {
            rightCast = true;
            rightTeleporter.ToggleDisplay(true);
        }
        else if (rightCast)
        {
            rightCast = false;
            rightTeleporter.Teleport();
            rightTeleporter.ToggleDisplay(false);
        }
    }
    private void Update()
    {
        stickvalue = -inputManager.stick.y;

        if (stickvalue > minStickValue)
        {
            if (Mathf.Abs(stickvaluePrev) < minStickValue && !isActive)
            {
                teleporter.ToggleDisplay(true);
                isActive = true;
                //Debug.Log("XRTeleporterController:: Enabled");
            }
            strength            = stickvalue;
            strength            = Mathf.Clamp(strength, 0.1f, 1f);
            teleporter.strength = strength * distanceMult;
        }
        else if (isActive)
        {
            teleporter.ToggleDisplay(false);
            isActive = false;
            //Debug.Log("XRTeleporterController:: Disabled");
        }

        if (isActive && inputManager.IsTriggerButtonUp())
        {
            teleporter.Teleport();
            teleporter.ToggleDisplay(false);
            StartCoroutine("_DisableTeleportTimed");
            //Debug.Log("XRTeleporterController:: Disabled");
        }

        stickvaluePrev = stickvalue;
    }
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            teleporter.ToggleDisplay(true);
        }

        if (Input.GetMouseButtonUp(0))
        {
            teleporter.Teleport();
            teleporter.ToggleDisplay(false);
        }
    }
Exemple #4
0
    // Update is called once per frame
    void Update()
    {
        if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstick, OVRInput.Controller.LTouch))
        {
            Debug.Log("Thumbstick Pressed");
            teleporter.ToggleDisplay(true);
        }

        if (OVRInput.GetUp(OVRInput.Button.PrimaryThumbstick, OVRInput.Controller.LTouch))
        {
            Debug.Log("Thumbstick released");
            teleporter.Teleport();
            teleporter.ToggleDisplay(false);
        }
    }
Exemple #5
0
    private void Update()
    {
        if (side == handSide.Right)
        {
            if (Input.GetButtonDown(trackPad))
            {
                teleporter.ToggleDisplay(true);
            }

            if (Input.GetButtonUp(trackPad))
            {
                teleporter.Teleport();
                teleporter.ToggleDisplay(false);
            }
        }
    }
Exemple #6
0
    // Update is called once per frame
    void Update()
    {
        handTriggerState = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, controller);

        if (rightHand)
        {
            primaryTouched = OVRInput.Get(OVRInput.Touch.One, controller);
            primaryDown    = OVRInput.Get(OVRInput.Button.One, controller);
            //print("Touched: " + primaryTouched + "Presssed: " + primaryDown);

            if (primaryTouched)
            {
                teleporter.ToggleDisplay(false);
                teleporter.ToggleDisplay(true);
            }

            if (previousPrimaryTouched && !primaryTouched)
            {
                teleporter.ToggleDisplay(false);
            }

            if (!previousPrimaryDown && primaryDown)
            {
                teleporter.Teleport();
            }

            previousPrimaryTouched = primaryTouched;
            previousPrimaryDown    = primaryDown;
        }

        if (grabbingObject)
        {
            if (handTriggerState < 0.9f)
            {
                Release();
            }
        }
    }
Exemple #7
0
 // Start is called before the first frame update
 void Start()
 {
     Cursor.gameObject.SetActive(false);
     teleporter.ToggleDisplay(false);
     Camera = GestureProvider.Current.transform;
 }
Exemple #8
0
 // Use this for initialization
 void Start()
 {
     teleporter = gameObject.GetComponentInChildren <VRTeleporter>();
     teleporter.ToggleDisplay(true);
     StartCoroutine(PostScores());
 }
Exemple #9
0
 //When the user looks at the floor, this function is called to display the teleportation target.
 public void TurnOnDisplay()
 {
     teleporter.ToggleDisplay(true);
 }
Exemple #10
0
    // Update is called once per frame
    void Update()
    {
        if (secondaryHand.collisionEnabled)
        {
            secondaryHand.DisableCollision();
        }

        NVRInputDevice primaryInput   = primaryHand.GetComponent <NVRInputDevice>();
        NVRInputDevice secondaryInput = secondaryHand.GetComponent <NVRInputDevice>();

        //Allow player to turn rapidly with secondary joystick
        float joystickX = secondaryHand.Inputs[NVRButtons.Touchpad].Axis.x;

        if (!justRotated && Mathf.Abs(joystickX) >= rotateThreshold)
        {
            float rotation = rotationAmount * Mathf.Sign(joystickX);

            player.transform.Rotate(new Vector3(0, rotation, 0));
            justRotated = true;
        }
        else if (justRotated && Mathf.Abs(joystickX) < rotateThreshold)
        {
            justRotated = false;
        }

        //Allow "pulling" movement by gripping with secondary hand
        if (secondaryHand.HoldButtonDown)
        {
            //Set anchor
            prevHandPosition = secondaryHand.CurrentPosition;
        }
        else if (secondaryHand.HoldButtonPressed)
        {
            //Move player
            Vector3 delta = secondaryHand.transform.position - prevHandPosition;
            player.transform.Translate(-delta);
        }
        else
        {
            //Allow player to teleport with secondary hand
            if (secondaryHand.UseButtonDown)
            {
                teleporter.ToggleDisplay(true);
            }
            else if (secondaryHand.UseButtonUp)
            {
                float playerHeight = player.transform.position.y;
                teleporter.Teleport();
                teleporter.ToggleDisplay(false);
                player.transform.position = new Vector3(player.transform.position.x, playerHeight, player.transform.position.z);
            }
        }

        //Pressing A resets player position
        if (primaryInput.GetPressDown(NVRButtons.A))
        {
            player.transform.position = startingPosition;
        }

        //Terraform
        if (primaryHand.UseButtonDown && terraformController.isActiveAndEnabled)
        {
            terraformController.Click();
        }
    }