Пример #1
0
    void FixedUpdate()
    {
        OVRInput.FixedUpdate();

        if (_gameEnded)
        {
            if (!_restarted)
            {
                TextLabel.text = string.Format("Press trigger to restart{0}Your time was: {1}", Environment.NewLine,
                                               _gameEndTimeSpan.ToCounterTimeString());

                // wait for user input so user has time to read his/her time/score
                if (OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger))
                {
                    TextLabel.text = "restarting";
                    ResetLevel();
                    _restarted = true;
                }
            }
        }
        else
        {
            var referenceTime = DateTime.UtcNow;
            var timeSpan      = referenceTime - _startTime;

            TextLabel.text = string.Format("Points: {0}{1}Time: {2}", Points, Environment.NewLine, timeSpan.ToCounterTimeString());

            // resets level as soon as back button was pressed and released
            if (OVRInput.GetUp(OVRInput.Button.Back))
            {
                ResetLevel();
            }
        }
    }
Пример #2
0
 void FixedUpdate()
 {
     OVRInput.FixedUpdate();
     grip = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger);
     controller.SetFloat("Grip", grip);
     print("" + OVRInput.GetConnectedControllers());
 }
Пример #3
0
 void FixedUpdate()
 {
     if (VRDevice.OculusGo)
     {
         OVRInput.FixedUpdate();
     }
 }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        OVRInput.Update();
        OVRInput.FixedUpdate();

        if (highlighted && triggerPressed == false)
        {
            if (Input.GetAxis("FireTrigger") == 1)
            {
                if (mode != Mode.Toggle)
                {
                    if (selected == false)
                    {
                        ButtonEffect();
                        triggerPressed = true;
                    }
                }
                else
                {
                    ButtonEffect();
                    triggerPressed = true;
                }
            }
        }

        if (Input.GetAxis("FireTrigger") < 1)
        {
            triggerPressed = false;
        }
    }
Пример #5
0
 private void FixedUpdate()
 {
     if (OVRManager.instance == null)
     {
         OVRInput.FixedUpdate();
     }
 }
    void FixedUpdate()
    {
        OVRInput.FixedUpdate();

        HandleRotation();
        HandleSpeed();
    }
Пример #7
0
    // Update is called once per frame
    void Update()
    {
        OVRInput.SetControllerVibration(0, 0, OVRInput.Controller.RTouch);
        audios[audioIndex].Pause();
        lineRenderer.enabled = false;
        OVRInput.FixedUpdate();
        right_press = OVRInput.Get(OVRInput.RawButton.RIndexTrigger);

        RaycastHit hit;

        if (right_press)
        {
            Shoot();
            Debug.Log("&&&& CLICK");

            if (Physics.Raycast(controller.transform.position, controller.transform.TransformDirection(Vector3.left), out hit, Mathf.Infinity))
            {
                if (hit.collider.CompareTag("Fire"))
                {
                    Debug.Log("&&&& HIT");
                    healthBar.UpdateBar(healthBar.GetCurrentFraction - 0.0025f, 1f);
                    OVRInput.SetControllerVibration(1, 1, OVRInput.Controller.RTouch);
                }
            }
        }
    }
 void FixedUpdate()
 {
     OVRInput.FixedUpdate();
     // XUpTransform = Input.GetAxis("Horizontal");
     HandleRotation();
     HandleSpeed();
 }
Пример #9
0
    // Update is called once per frame
    void Update()
    {
        OVRInput.Update();
        OVRInput.FixedUpdate();
        float keyboardtrans = Input.GetAxis("Vertical") * speed;
        float straffe       = Input.GetAxis("Horizontal") * speed;

        keyboardtrans *= Time.deltaTime;
        straffe       *= Time.deltaTime;

        transform.Translate(straffe, 0, keyboardtrans);

        if (OVRInput.GetDown(OVRInput.Button.One))
        {
            Debug.Log("PressedOne");
        }

        Vector2 translation = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick) * speed;

        translation *= Time.deltaTime;
        // Debug.Log(OVRInput.IsControllerConnected(OVRInput.Controller.RTouch));
        transform.position += new Vector3(translation.x, 0, translation.y);

        if (Input.GetKeyDown("escape"))
        {
            Cursor.lockState = CursorLockMode.None;
        }
    }
Пример #10
0
 private void FixedUpdate()
 {
     // If used without a OVRManager in the scene
     if (OVRManager.instance == null)
     {
         OVRInput.FixedUpdate();
     }
 }
Пример #11
0
    void Update()
    {
        OVRInput.Update();
        OVRInput.FixedUpdate();

        UpdateGrounded();

        CheckForInput();

        ApplyInput();
    }
Пример #12
0
    //定期的に呼ばれる
    void FixedUpdate()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        OVRInput.FixedUpdate();

        Vector2 vector = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad, OVRInput.Controller.RTrackedRemote);
        float   x      = vector.x;
        float   z      = vector.y;
        if (x < 180)
        {
            x += 720;
        }
        if (z < 180)
        {
            z += 720;
        }
        float h = (Math.Min((360f - z), 45f) / 45f) * 1f;
        float v = (Math.Min((x - 360f), 10f) / 10f) * 20f;
#else
        //VR用の車操作
        float x = camera.transform.localEulerAngles.x;
        float z = camera.transform.localEulerAngles.z;
        if (x < 180)
        {
            x += 360;
        }
        if (z < 180)
        {
            z += 360;
        }
        float h = (Math.Min((360f - z), 45f) / 45f) * 1f;
        float v = (Math.Min((x - 360f), 10f) / 10f) * 20f;
#endif


        //キーボード用の車操作
        if (h == 0f && v == 0f)
        {
            h = Input.GetAxis("Horizontal") * 1f;
            v = Input.GetAxis("Vertical") * 20f;
        }

        //車の向きと加速度の指定
        if (v != 0f)
        {
            this.gameObject.transform.Rotate(0, (v > 0) ? h : -h, 0);
        }
        this.rb.velocity = this.gameObject.transform.rotation *
                           new Vector3(0, 0, v);
    }
    // Update is called once per frame
    void Update()
    {
        OVRInput.Update();
        OVRInput.FixedUpdate();

        if (highlighted)
        {
            if (Input.GetAxis("FireTrigger") == 1)
            {
                if (!selected)
                {
                    SelectColor();
                }
            }
        }
    }
Пример #14
0
    // Update is called once per frame
    void Update()
    {
        OVRInput.Update();
        OVRInput.FixedUpdate();

        if (grabbing)
        {
            if (rightTouch)
            {
                if (Input.GetAxis("RGripTrigger") < 1)
                {
                    DropObject();
                }
            }
            else
            {
                if (Input.GetAxis("LGripTrigger") < 1)
                {
                    DropObject();
                }
            }
        }
        if (!grabbing)
        {
            if (rightTouch) //check to see if this is the right or left controller
            {
                if (Input.GetAxis("RGripTrigger") == 1)
                {
                    GrabObject();
                }
            }
            else
            {
                if (Input.GetAxis("LGripTrigger") == 1)
                {
                    GrabObject();
                }
            }
        }
        if (grabbing && grabbedObject != null)
        {
            RotateGrabbedObjectWithThumbstick();
        }
    }
Пример #15
0
    // Update is called once per frame
    void Update()
    {
        DatabaseConnection dbConnection = new DatabaseConnection();

        OVRInput.Update();
        OVRInput.FixedUpdate();
        var        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit Hit;

        if (Input.GetMouseButtonDown(0) || OVRInput.Get(OVRInput.Button.One))
        {
            if (Physics.Raycast(ray, out Hit) && Hit.collider.gameObject == gameObject)
            {
                //SceneManager.LoadScene("Product Scene");
                Initiate.Fade("Product Scene", Color.black, 2.0f);  //This will change the scene using Fade to black animation!!!
                //dbConnection.openDatabaseConnection();
                OnClick.Invoke();
            }
        }
    }
Пример #16
0
    // Called at a constant rate
    void FixedUpdate()
    {
        // If we are in VR...
        if (UnityEngine.XR.XRSettings.enabled)
        {
            // Update oculus input system
            OVRInput.FixedUpdate();

            // Get any button
            m_CanPush = OVRInput.Get(OVRInput.Button.Any);
        }
        // If we are on standalone...
        else
        {
            m_CanPush = Input.GetMouseButtonDown(0);
        }

        // Emulate GetDown (only allow one true per frame)
        if (m_LastKnownCanPush && m_CanPush)
        {
            m_CanPush = false;
        }
        else if (m_LastKnownCanPush && !m_CanPush)
        {
            // allow to change state of last known
            m_LastKnownCanPush = false;
        }

        // Trigger activates the push
        if (m_CanPush && IsBoxInSight)
        {
            // Add a bit of noise to the direction
            Vector3 pushRandom = new Vector3(Random.Range(-0.5f, 0.5f), Random.Range(-0.5f, 1), Random.Range(-1, 1));
            // Push box
            m_Rigidbody.AddForce(PushDirection * PushStrength, ForceMode.Impulse);

            Debug.Log("Force applied");

            m_LastKnownCanPush = m_CanPush;
        }
    }
    void Update()
    {
        // call these two if you want OVR controller Input
        OVRInput.Update();
        OVRInput.FixedUpdate();

        //pressedThisFrame will only be triggered like GetButtonDown, and pressedLastFrame will remain true until you stop pressing the specified button.
        pressedThisFrame = OVRInput.Get(pauseButton) && !pressedLastFrame;

        if (pressedThisFrame)
        {
            if (!GameIsPaused)
            {
                Pause();
            }
            else if (GameIsPaused)
            {
                Resume();
            }
        }

        /* PROBLEM - if this then you cannot pause physics for Player.GameState.Lose
         * if (GameIsPaused)
         * {
         *  Time.timeScale = 0f;
         * }
         * if (!GameIsPaused)
         * {
         *  Time.timeScale = 1f;
         * }
         */
        pressedLastFrame = OVRInput.Get(pauseButton);
        for (int i = 0; i < pauseEffect.Count; i++)
        {
            pauseEffect[i].SetActive(GameIsPaused);
        }
    }
Пример #18
0
 private void FixedUpdate()
 {
     OVRInput.FixedUpdate();
 }
Пример #19
0
 // Update is called once per frame
 void Update()
 {
     //OVR Input Checks
     OVRInput.Update();// ALWAYS call this if you want
     OVRInput.FixedUpdate();
     SavePlayer();
     //Start
     if (currentState == GameState.Start)
     {
         pauseGameController.enabled = false;       // is pausing allowed in this state?
         for (int i = 0; i < loseEffect.Count; i++) //ensure game is not showing that it is failed
         {
             loseEffect[i].SetActive(false);
         }
         rb.isKinematic = true;
         if (startTime == 0f)
         {
             startTime = Time.time;
         }
         if (Time.time > startTime + StartDelay)
         {
             countDownComplete = true;
         }
         else
         {
             countDownComplete = false;
         }
         if (!countDownComplete)
         {
             rb.isKinematic = true;
             CountDownObject.SetActive(true);
         }
         if (countDownComplete)
         {
             currentState = GameState.Play;
             CountDownObject.SetActive(false);
             rb.isKinematic = false;
             GameStart(Vector3.zero, true);
             startTime = 0f;
         }
     }
     //Play
     if (currentState == GameState.Play)
     {
         pauseGameController.enabled = true; // is pausing allowed in this state?
         rb.isKinematic = false;
         Board.GetComponent <Rigidbody>().isKinematic = false;
         // check the box in the inspector if this is a build that is going on the Oculus Quest
         if (QuestBuild)
         {
             Height = transform.position.y - headset.transform.position.y;
             headsetRotateControls();
         }
         else
         {
             keyboardRotateControls();
         }
         if (Height >= heightBound && Height <= heightBound + 1)
         {
             float heightCurveY = this.heightCurve.Evaluate(Height - heightBound);
             rb.AddForce(transform.forward * -10 * heightCurveY);
         }
         // this is essentially my Air resistance, it keeps the player from going too fast if they are standing.
         //lockedRotation();
         preventBackClimbing();
         checkBounds();
         clampSpeed();
         jump();
     }
     if (currentState == GameState.Lose)
     {
         pauseGameController.enabled = false;// is pausing allowed in this state?
         LoseGame();
     }
     SceneSwitchOveride("q", "start3");
     SceneSwitchOveride("e", "5");
 }
Пример #20
0
 void FixedUpdate()
 {
     OVRInput.FixedUpdate(); //Must be run each fixed frame
 }
Пример #21
0
    void Update()
    {
        OVRInput.Update();
        OVRInput.FixedUpdate();
        if ((Input.GetKeyDown(Constants.interactionKey) || OVRInput.GetDown(OVRInput.Button.One)) && !finished)
        {
            Debug.Log("button pressed");
            // Get buttons pressed
            for (int i = 0; i < triggers.Length; i++)
            {
                if (triggers[i].highlighted)
                {
                    if (i < 10)
                    {
                        current += i;
                    }
                    else
                    {
                        current = current.Substring(0, current.Length - 1);
                    }
                }
            }

            //Debug.Log("Current");
            // Compare current
            if (current.Length == 4)
            {
                finished = true;
            }

            if (CodeSolved)
            {
                Debug.Log("CodeSolved!");
            }
        }
        if (finished)
        {
            timer += Time.deltaTime;
        }
        if (timer >= DELAY)
        {
            finished = false;
            timer    = 0;
            Clear();
        }

        for (int i = 0; i < triggers.Length; i++)
        {
            int num = current.LastIndexOf(i.ToString());
            //Debug.Log(this.histcolor[0]);
            Renderer rend = triggers[i].transform.parent.GetComponentInParent <Renderer>();
            if (num != -1)
            {
                rend.material.SetColor("_Color", histcolor[num]);
            }
            else
            {
                rend.material.SetColor("_Color", Color.white);
            }
            if (finished && timer > DELAY / 2)
            {
                if ((int)(timer / BLINK) % 2 == 0)
                {
                    rend.material.SetColor("_Color", Color.white);
                }
                else
                {
                    if (current.Equals(CORRECT))
                    {
                        rend.material.SetColor("_Color", Color.green);
                    }
                    else
                    {
                        rend.material.SetColor("_Color", Color.red);
                    }
                }
            }
        }
    }
Пример #22
0
    // Update is called once per frame
    void Update()
    {
        OVRInput.Update();
        OVRInput.FixedUpdate();

        if (OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger, OVRInput.Controller.RTouch) && fireTriggerReleased == false)
        {
            if (inFlight)
            {
                fireTriggerReleased = true;
                Fire();
                Debug.Log("fire pressed " + Time.time);
            }
        }
        if ((OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger, OVRInput.Controller.RTouch) == false))
        {
            fireTriggerReleased = false;
        }

        if (inFlight && Input.GetButtonDown(buttonName: "Submit"))
        {
            ReturnDrone();
        }

        if (inFlight == false && Input.GetAxis("LFireTrigger") == 1 && droneAvailable)
        {
            LaunchDrone();
        }

        if (inFlight)
        {
            switch (controlMode)
            {
            case FlightControlMode.MotionControls: RotateWithController();
                break;

            case FlightControlMode.Thumbstick: RotateWithThumsticks();
                break;
            }
            Accelerate();
            Firing();
            GetComponent <AudioSource>().pitch = speed;
            transform.position += transform.forward * Time.deltaTime * speed;
        }
        else
        {
            if (Input.GetButtonDown(buttonName: "Submit"))
            {
                if (shipDetails.FullyEquipped())
                {
                    CreateDrone();
                    SetDroneActive(!droneAvailable);
                    AudioSource.PlayClipAtPoint(toggleDroneSFX, transform.position);
                }
                else
                {
                    AudioSource.PlayClipAtPoint(errorSFX, transform.position);
                }
            }
        }
    }
Пример #23
0
 void FixedUpdate()
 {
     OVRInput.FixedUpdate();
     ProcessAudio();
 }
Пример #24
0
    // Update is called once per frame
    void Update()
    {
        OVRInput.Update();
        OVRInput.FixedUpdate();
        if ((Input.GetKeyDown(KeyCode.E) || OVRInput.GetDown(OVRInput.Button.One)) && !finished)
        {
            // Check every button
            for (int i = 0; i < tiles.Length; i++)
            {
                if (tiles[i].highlighted)
                {
                    // Gets index of emptytile in currentArray
                    int emptyIndex = Array.IndexOf(currentArray, emptyTile);
                    Debug.Log(emptyIndex);

                    if ((i < currentArray.Length) && ((i == emptyIndex - 3) || (i == emptyIndex + 3) || (i == emptyIndex + 1 && emptyIndex % 3 != 2) ||
                                                      (i == emptyIndex - 1 && emptyIndex % 3 != 0)))
                    {
                        // Swap colors in currColor
                        Color tempColor = currColors[emptyIndex];
                        currColors[emptyIndex] = currColors[i];
                        currColors[i]          = tempColor;

                        Renderer rend = tiles[emptyIndex].transform.parent.GetComponentInParent <Renderer>();
                        rend.material.SetColor("_Color", currColors[emptyIndex]);
                        rend = tiles[i].transform.parent.GetComponentInParent <Renderer>();
                        rend.material.SetColor("_Color", currColors[i]);

                        // Swap values in currentArray
                        currentArray[emptyIndex] = currentArray[i];
                        currentArray[i]          = emptyTile;
                    }
                    // Reset button
                    else if (i == 9)
                    {
                        Setup();
                    }

                    string str = "";
                    for (int j = 0; j < currentArray.Length; j++)
                    {
                        str += currentArray[j] + ",";
                    }
                    //Debug.Log("Array is " + str);
                }
            }

            int sameNums = 0;
            // Check if currentArray is equal to correctArray
            for (int i = 0; i < currentArray.Length; i++)
            {
                if (currentArray[i] == correctArray[i])
                {
                    sameNums++;
                }
            }

            finished = sameNums == 9;

            // Print puzzle solved if finished
            if (finished)
            {
                Debug.Log("Puzzle solved!");
            }
        }
    }
Пример #25
0
    // FixedUpdate is called once per frame and deals with Physics
    private void FixedUpdate()
    {
        // Updates app with remote inputs
        OVRInput.FixedUpdate();

        // If player presses touch button/spacebar from ground then jump in the air
        if ((OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger) || Input.GetKeyDown(KeyCode.Space)) && rb.position.y < 4.2f)
        {
            rb.AddExplosionForce(jump * Time.deltaTime, rb.position, 7f, 9f, ForceMode.Impulse);
        }
        // If player is in the air, increase gravity
        if (rb.velocity.y > 0)
        {
            rb.AddForce(Vector2.down * Physics2D.gravity.y * fall * Time.deltaTime);
        }
        // If touch position on x/y touchpad is found
        if ((OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad).x != 0) && (OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad).y != 0))
        {
            touch_x = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad).x;
            touch_y = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad).y;

            if (touch_x < 0 && touch_y < 0)
            {
                //If negative x/y then compare values
                if (touch_y <= touch_x)
                {
                    //fbforce
                    rb.AddForce(new Vector3(touch_x * damper, 0, touch_y) * umovement * Time.deltaTime, ForceMode.Impulse);
                    rb.AddTorque(new Vector3(touch_y, 0, touch_x * damper) * umovement * Time.deltaTime, ForceMode.Impulse);
                }
                else
                {
                    //sbs
                    rb.AddForce(new Vector3(touch_x, 0, touch_y * damper) * umovement * Time.deltaTime, ForceMode.Impulse);
                    rb.AddTorque(new Vector3(0, touch_x * damper, touch_y) * umovement * Time.deltaTime, ForceMode.Impulse);
                }
            }
            else
            {
                if (touch_y >= touch_x)
                {
                    //fbforce
                    rb.AddForce(new Vector3(touch_x * damper, 0, touch_y) * umovement * Time.deltaTime, ForceMode.Impulse);
                    rb.AddTorque(new Vector3(touch_y, 0, touch_x * damper) * umovement * Time.deltaTime, ForceMode.Impulse);
                }
                else
                {
                    //sbs
                    rb.AddForce(new Vector3(touch_x, 0, touch_y * damper) * umovement * Time.deltaTime, ForceMode.Impulse);
                    rb.AddTorque(new Vector3(0, touch_x * damper, touch_y) * umovement * Time.deltaTime, ForceMode.Impulse);
                }
            }
        }
        else
        {
            //get speed on x & y axis
            speed_x = Input.GetAxis("Horizontal");
            speed_y = Input.GetAxis("Vertical");

            //If w is pressed move the z axis forward 500 + Rotate Player
            if (Input.GetKey("w") || Input.GetKey(KeyCode.UpArrow))
            {
                //fbforce
                rb.AddForce(Vector3.forward * umovement * Time.deltaTime, ForceMode.Impulse);
                rb.AddTorque(new Vector3(speed_y, 0, speed_x) * umovement * Time.deltaTime, ForceMode.Impulse);
            }
            //If s is pressed move the z axis back 500
            if (Input.GetKey("s") || Input.GetKey(KeyCode.DownArrow))
            {
                //fbforce
                rb.AddForce(Vector3.back * umovement * Time.deltaTime, ForceMode.Impulse);
                rb.AddTorque(new Vector3(speed_y, 0, speed_x) * -umovement * Time.deltaTime, ForceMode.Impulse);
            }

            //If d is pressed move the x axis 500
            if (Input.GetKey("d") || Input.GetKey(KeyCode.RightArrow))
            {
                //sbs
                rb.AddForce(Vector3.right * umovement * Time.deltaTime, ForceMode.Impulse);
                rb.AddTorque(new Vector3(0, speed_x, speed_y) * umovement * Time.deltaTime, ForceMode.Impulse);
            }

            //If a is pressed move the x axis -500
            if (Input.GetKey("a") || Input.GetKey(KeyCode.LeftArrow))
            {
                //sbs
                rb.AddForce(Vector3.left * umovement * Time.deltaTime, ForceMode.Impulse);
                rb.AddTorque(new Vector3(0, speed_x, speed_y) * -umovement * Time.deltaTime, ForceMode.Impulse);
            }
        }
    }
Пример #26
0
 public virtual void FixedUpdate()
 {
     OVRInput.FixedUpdate();
 }