Search Unity

  1. Read here for Unity's latest plans on OpenXR.
    Dismiss Notice

Oculus Touch Input Not Detected

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

  1. Harrisonhough

    Harrisonhough

    Joined:
    May 13, 2014
    Posts:
    12
    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:
    12
    ---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....
     
    viciousesque and Shizola like this.
  3. Harrisonhough

    Harrisonhough

    Joined:
    May 13, 2014
    Posts:
    12
    For anyone that has a similar problem, it seems to be working now. Ever since I used the Oculus home button.
     
    viciousesque likes this.
  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:
    308
    @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:
    11
    Thank you for posting this, I spent a whole day trying to figure this out.
     
  7. Shizola

    Shizola

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

    Tset_Tsyung

    Joined:
    Jan 12, 2016
    Posts:
    372
    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:
    5
    +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:
    151
    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:
    372
    Just checking, have you installed the Oculus Integration as well as the Oculus Package through the package manager?
     
  12. lostjam

    lostjam

    Joined:
    Mar 11, 2019
    Posts:
    1
    I'm also still having this issue :< none of the above solutions have worked yet
     
  13. tomszirtes

    tomszirtes

    Joined:
    Apr 25, 2013
    Posts:
    20
    I've got this problem too I believe its related to updating the Oculus Spatializer - basically don't... no idea why
     
  14. FloHal

    FloHal

    Joined:
    Feb 25, 2013
    Posts:
    36
    I have the same issue. OVRInput.Get(OVRInput.Button.One) always return false...
    CustomHand prefab from Oculus Integration 1.41 just not work. Yes my hand move related to my controller position but finger doesn't react when i pressing buttons...

    I tried on Unity 2019.3.9b and 2018.4.12f1...

    I have an Oculus Quest.
     
  15. FloHal

    FloHal

    Joined:
    Feb 25, 2013
    Posts:
    36
    i found the solution by myself. XR Management was imported to my scene. So make sure that XR Management (installed from PackageManager) is not installed with your project.
     
  16. milad-y

    milad-y

    Joined:
    Sep 30, 2018
    Posts:
    2
    I coded my unity project on 2018.3.13 version. It was working fine when I copied my file project and run it in another pc this problem appeared for me the versions of unity were the same and the Ovr packages were inside the project. OVRInput.Get(OVRInput.Button.One) doesn't return anything I can move around by joystick. can it be something related to the oculus app ??!!
     
  17. mastermindtyc

    mastermindtyc

    Joined:
    Feb 10, 2014
    Posts:
    1
    Using Unity 2020.1 and pressing the Oculus Home button on the Right Touch and then press again to close the input works for me too.
     
  18. Discmage

    Discmage

    Joined:
    Aug 11, 2014
    Posts:
    39
    I managed to get this working when the new XR management process in 2019.3. Unity seems to add items into the standard Input Manager in the Project settings section...I used the following code to get them to work...


    if (Input.GetAxis("Oculus_CrossPlatform_SecondaryIndexTrigger") >= 0.9f && isLoaded) {
    ShootArrow();
    }

    if (Input.GetButtonDown("Fire1") && !isLoaded) {
    LoadArrow();
    }


    With those two examples (triggers and buttons) you should be able to figure out the rest. Sometimes you need to do the home button/reset view thing (but I found this was not the case once I figured it out, but maybe it worked better after doing this once).

    I also noted that it may not work unless something is covering the sensor to make sure something is in the headset eg. a head...so cover that up with a finger or something maybe. Kind of makes sense, but not so good for quick testing.

    Basically I don't use the OVRInput anymore.
     
  19. viciousesque

    viciousesque

    Joined:
    Oct 4, 2014
    Posts:
    34
    It's March 2020 and this is still happening, and the Oculus Home button fix still works.

    Thanks for saving me hours of frustration! I luckily found this post just a few minutes after starting to get frustrated. :))
     
  20. viciousesque

    viciousesque

    Joined:
    Oct 4, 2014
    Posts:
    34
    *facepalm*
    Looks like the issue (in my instance) is the HMD needs to begin tracking before Touch controllers fully activate.

    The HMD sensor is just at the center top. I can either slip the HMD on real fast or cover sensor with my thumb. Once you hear the chime, the OVRInput button outputs begin returning as expected.
     
unityunity