Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
nerdVRBuddy's avatar
9 years ago
Solved

How do you detect Touch button and Trigger presses?

I'm a beginner. Not great scripter. just a hobby. But i got Touch controllers and Unity and I want to detect user pressing buttons or the triggers for a little game i'm making.

How do i go about it?   I already figured out how to get the Oculus Touch controllers in my game. But i don't know anything about how to detect buttons and triggers.


I have in the past figured out how to detect button presses in the XBOX controller. Is it similar way?
  • Hi,

    There are a couple different methods to detect button presses.
    // returns true if the primary button (typically “A”) is currently pressed.
    OVRInput.Get(OVRInput.Button.One);

    You may also specify a controller 
    // returns true if the "A" button is pressed on the Right Touch Controller.
    OVRInput.Get(OVRInput.Button.One, OVRInput.Controller.RTouch);

    To detect trigger presses:
    // returns a float of the Hand Trigger’s current state on the Left Oculus Touch controller.
    OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, OVRInput.Controller.LTouch);

    The rest of documentation can be found here:
    https://developer.oculus.com/documentation/unity/latest/concepts/unity-ovrinput/#unity-ovrinput-touch


4 Replies

Replies have been turned off for this discussion
  • juanoldinho's avatar
    juanoldinho
    Heroic Explorer
    Hi,

    There are a couple different methods to detect button presses.
    // returns true if the primary button (typically “A”) is currently pressed.
    OVRInput.Get(OVRInput.Button.One);

    You may also specify a controller 
    // returns true if the "A" button is pressed on the Right Touch Controller.
    OVRInput.Get(OVRInput.Button.One, OVRInput.Controller.RTouch);

    To detect trigger presses:
    // returns a float of the Hand Trigger’s current state on the Left Oculus Touch controller.
    OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, OVRInput.Controller.LTouch);

    The rest of documentation can be found here:
    https://developer.oculus.com/documentation/unity/latest/concepts/unity-ovrinput/#unity-ovrinput-touch


  • JVVince's avatar
    JVVince
    Honored Guest
    @nerdVRBuddy
    First sorry for comment a question inside your thread. I'm facing the same problem so I think to post here will be easier to follow.
    @juanoldinho
    Hi juanoldinho, I go around the internet, read all the documentation that you gave (I through it before) and I tried all but not thing help. My touch controller has only recognized the touch event and when I press the button, nothing work.
    Here is my environment:
    My project is not using HMD so I set the camera target eye to None. OVRManager gameobject set. I'm using unity 2018.1.6f1 and Oculus Util Plugin 1.25.0. 
    Please support me.