Search Unity

Oculus Touch Input Not Detected

Discussion in 'VR' started by Harrisonhough, Aug 26, 2018.

  1. Harrisonhough

    Harrisonhough

    Joined:
    May 13, 2014
    Posts:
    8
    Hey Guys I am using Unity 2018.2.5f1 and running the oculus app software version 1.29.0.651191. Also using the OVR manager from the Oculus Integration plugin version 1.27 from the Unity asset store https://assetstore.unity.com/packages/tools/integration/oculus-integration-82022.

    So I am just trying to implement the button input for the touch controls using the following script.
    for now I am just trying to get the triggers working. but the

    Code (CSharp):
    1. OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, OVRInput.Controller.Touch)
    Always returns 0 ( on both controllers) and I can't figure out why.
    I have OVR manager in the scene (and active) but I also added in OVR.Update() and OVR.FixedUpdate() just in case but doesn't seem to make a difference.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. //Left touch trigger : Axis 9 (0 -> 1 )
    6. //Right touch trigger : Axis 10 (0 -> 1 )
    7. //Left Joystick Horizontal  : Axis 1 (-1 -> 1)
    8. //Left Joystick Vertical : Axis 2 (-1 -> 1)
    9. //Right Joystick Horizontal : Axis 3 (-1 -> 1)
    10. //Right Joystick Vertical : Axis 4 (-1 -> 1)
    11.  
    12. public class PlayerInputVR : MonoBehaviour {
    13.  
    14.     [SerializeField]
    15.     private Weapon weaponLeft;
    16.     [SerializeField]
    17.     private Weapon weaponRight;
    18.  
    19.     private bool firingLeft = false;
    20.     private bool firingRight = false;
    21.  
    22.     OVRManager ovrManager;
    23.     // Use this for initialization
    24.     void Start () {
    25.         //ovrManager.
    26.     }
    27.  
    28.     // Update is called once per frame
    29.     void Update () {
    30.         OVRInput.Update();
    31.         WeaponFire();
    32.         WeaponSwitch();
    33.         if (Input.GetKeyUp(KeyCode.Escape))
    34.         {
    35.             GameManager.Instance.PauseToggle();
    36.         }
    37.     }
    38.     private void FixedUpdate()
    39.     {
    40.         OVRInput.FixedUpdate();
    41.     }
    42.  
    43.     void WeaponFire()
    44.     {
    45.         float leftTrigger = OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, OVRInput.Controller.Touch);
    46.         //float rightTrigger = OVRInput.Get(OVRInput.Axis1D.SecondaryIndexTrigger, OVRInput.Controller.Touch);
    47.         float rightTrigger = OVRInput.Get(OVRInput.Axis1D.SecondaryIndexTrigger);
    48.      
    49.         Debug.Log("WEAPON FIRE UPDATE - LT = " + leftTrigger + " RT = " + rightTrigger);
    50.         if (leftTrigger != 0)
    51.         {
    52.             Debug.Log("LEFT TRIGGER PRESS DETECTED");
    53.             if (!firingLeft)
    54.             {
    55.                 firingLeft = true;
    56.                 weaponLeft.Fire();
    57.                 Debug.Log("FIRE WEAPON");
    58.             }
    59.         }
    60.         /*if (leftTrigger == 0)
    61.         {
    62.             Debug.Log("STOP FIRE WEAPON");
    63.             firingLeft = false;
    64.         }*/
    65.  
    66.         if(rightTrigger != 0)
    67.         {
    68.  
    69.             if (!firingRight)
    70.             {
    71.                 firingRight = true;
    72.                 weaponRight.Fire();
    73.             }
    74.         }
    75.         /*if (rightTrigger == 0)
    76.         {
    77.             firingRight = false;
    78.         }*/
    79.  
    80.     }
    81.  
    82.     void WeaponSwitch()
    83.     {
    84.  
    85.      
    86.     }
    87. }
    88.  
    Also might be worth mentioning if I put this in an update method.

    Code (CSharp):
    1. print("" + OVRInput.GetConnectedControllers());
    it DOES print "Touch".
     
  2. Harrisonhough

    Harrisonhough

    Joined:
    May 13, 2014
    Posts:
    8
    ---UPDATE---
    BTW all the above was from running it in Editor, haven't tested as a build yet.

    Also it seems that once running in editor, if I press the Oculus Home button on the Right Touch and then press again to close the input starts to work....
     
    Shizola likes this.
  3. Harrisonhough

    Harrisonhough

    Joined:
    May 13, 2014
    Posts:
    8
    For anyone that has a similar problem, it seems to be working now. Ever since I used the Oculus home button.
     
  4. radicalappdev

    radicalappdev

    Joined:
    Aug 15, 2017
    Posts:
    1
    I can confirm that this is still an issue as of Nov 4, 2018. Unity version 2018.2.11f1 and Oculus Utilities version 1.28.0.

    Harrisonhough, thanks for the workaround.
     
  5. Freaking-Pingo

    Freaking-Pingo

    Joined:
    Aug 1, 2012
    Posts:
    299
    @Harrisonhough thank you for the workaround. We tried restarting headset, controllers, computer editor. But nothing worked. But after clicking the home button and back again, it started working. What a strange bug.
     
  6. optijapan

    optijapan

    Joined:
    Nov 22, 2017
    Posts:
    10
    Thank you for posting this, I spent a whole day trying to figure this out.
     
  7. Shizola

    Shizola

    Joined:
    Jun 29, 2014
    Posts:
    176
    Me too, ridiculous bug.
     
  8. Tset_Tsyung

    Tset_Tsyung

    Joined:
    Jan 12, 2016
    Posts:
    355
    Sorry for continuing the Necro (but this is still a current bug...)

    If the above work around doens't work, make sure you're not running both Oculus and OpenVR API's. If you are, make sure they're both loading into Unity properly.

    I had to remove OpenVR, leaving Oculus API in there, and then disable/reenable VR integration in the player settings.
     
  9. CAwesome

    CAwesome

    Joined:
    Nov 28, 2014
    Posts:
    3
    +1 for mentioning this.

    I had issues with OVRInput.Button.One for both controllers, but all other inputs functioned. Removing OpenVR from the project and only using Oculus in Project Settings/Player/XR worked for me.
     
    Tset_Tsyung likes this.
  10. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    81
    OVRInput.Get(OVRInput.Axis1D.SecondaryHandTrigger, OVRInput.Controller.RTouch always reports 0 for me. I can not read Rtouch controller at all. I do not have OpenVr and am only using Oculus in Project Settings/Player/XR.
     
    Last edited: Jun 2, 2019
  11. Tset_Tsyung

    Tset_Tsyung

    Joined:
    Jan 12, 2016
    Posts:
    355
    Just checking, have you installed the Oculus Integration as well as the Oculus Package through the package manager?