playMaker

Author Topic: Oculus Go and Gear VR Controller Actions  (Read 4669 times)

HendrikB

  • Playmaker Newbie
  • *
  • Posts: 37
  • In love with Playmaker
    • View Profile
Oculus Go and Gear VR Controller Actions
« on: September 11, 2018, 02:28:54 PM »
** UPDATE - 2019/01/28**

For anyone doing Oculus Go or Gear VR projects and who need some custom actions to check for input from the VR controllers, I hope these will be of some use to you in your projects.

You can find all the actions I have created on my Github account: https://github.com/HendrikZA/general-playmaker/tree/master/oculus%20go%20and%20gear%20vr

Here is a list of the current actions I have created for everyone to use.

OculusGoButtonDown.cs
This was the initial action I wrote which contains many of the features of the others below in a single action. I prefer using the smaller actions below as it looks neater in the FSM :)

OculusGoBackButton.cs
Checks if the Oculus Go or Gear VR back button was pressed.

OculusGoCapacitiveTouch.cs
Check if the Oculus Go or Gear VR capacitive touchpad was touched, in which direction and you can also get the actual axis of the touches to use for FPS games etc.

OculusGoDpadButton.cs
Checks if the Dpad button was pressed or released.

OculusGoDpadDirection.cs
Checks if the Dpad button was pressed in a specific direction, such as up, down, right, left, or diagonally.

OculusGoDpadSwipes.cs
Checks if the Dpad was swiped in a specific direction.

OculusGoHMDStatus.cs
Checks if the Oculus Go headset is on the face or has been removed.

OculusGoInputSource.cs
Checks if the right-handed or left-handed controller is connected, or if only the headset is connected, e.g. Gear VR without controller

OculusGoPhysics.cs
Gets various useful statistics about the controller, such as acceleration, rotation, position or velocity.

OculusGoRotationAndDirection.cs
This can be used to detect if the controller has been rotated left or right with some force (for weapon switching, or for quick turns in FPS games as an example). It can also check if the controller is pointing directly up or down (useful for reloading gestures).

OculusGoTriggerButton.cs
Checks if the Oculus Go or Gear VR trigger button has been pressed or released.
« Last Edit: January 28, 2019, 06:24:28 AM by HendrikB »

WayneAdams

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
    • Glacier Studios
Re: Oculus Go and Gear VR Controller Actions
« Reply #1 on: October 02, 2018, 04:25:37 PM »
Heya.. I'm trying to give these a go right now but every time they copy over I get errors saying playmaker does not contain a definition for 'Custom'

I'm an artist with a little bit of programming knowledge and I've never added anything to playmaker outside of the ecosystem so I'm not sure how to fix it.

WayneAdams

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
    • Glacier Studios
Re: Oculus Go and Gear VR Controller Actions
« Reply #2 on: October 05, 2018, 09:42:29 PM »
FYI. I got these working by putting them in an existing category and so far they work like a charm. Well done. :)

HendrikB

  • Playmaker Newbie
  • *
  • Posts: 37
  • In love with Playmaker
    • View Profile
Re: Oculus Go and Gear VR Controller Actions
« Reply #3 on: December 30, 2018, 11:37:37 AM »
Hey Wayne,

Awesome glad you managed to get that to work. Apologies for the super delayed response, I didn't get any notifications for some reason that the thread had been replied to.

I went ahead and changed the Playmaker category to Input so it won't give that error now hopefully for future projects.

I am currently working on a complete action that has everything in it. So you can just drop one action in to a state, and select whatever you need from it. Busy coding it now and need to test it over the week. If all looks good I will update here on the forum and upload the script to Github for easy access too.

Cheers!

HendrikB

  • Playmaker Newbie
  • *
  • Posts: 37
  • In love with Playmaker
    • View Profile
Re: Oculus Go and Gear VR Controller Actions
« Reply #4 on: December 30, 2018, 04:05:19 PM »
Hi folks,

Ok I have done a complete re-write of the Oculus Go / Gear VR "OculusGoButtonDown" script. It includes all the main things you need, and can check for long press and released states.

Here is the download link from my Github for anyone that wishes to use this action in your projects: https://raw.githubusercontent.com/HendrikZA/general-playmaker/master/oculus%20go%20and%20gear%20vr/OculusGoButtonDown.cs

I really struggled however to check when the Touchpad is pressed down in an up, down, left and right position. Swipes are easy to check and are included in the action. But checking if the actual Touchpad is pressed down in each direction is harder. I suspect you need to use the Axis2D for the Touchpad to see where the finger is pressing, and then check if Touchpad is pressed down. I did try that in all kinds of ways and it didn't work though.

If anyone knows the code for OVRInput to check when Touchpad is pressed down in different directions please let me know so I can add it to the action for others to use.

Have a great 2019 ya all! Waiting in anticipation for Oculus Quest :)
« Last Edit: January 28, 2019, 06:25:34 AM by HendrikB »

HendrikB

  • Playmaker Newbie
  • *
  • Posts: 37
  • In love with Playmaker
    • View Profile
Re: Oculus Go and Gear VR Controller Actions
« Reply #5 on: December 30, 2018, 04:36:18 PM »
If anyone knows the code for OVRInput to check when Touchpad is pressed down in different directions please let me know so I can add it to the action for others to use.

Ok I figured it out :) My bad, I forgot to update the value with FsmVector2.Value :D I will add some logic now to the action to add these new features that this brings too.

HendrikB

  • Playmaker Newbie
  • *
  • Posts: 37
  • In love with Playmaker
    • View Profile
Re: Oculus Go and Gear VR Controller Actions
« Reply #6 on: December 30, 2018, 05:04:23 PM »
I've added the touchpad axis to the OculusGoButtonDown.cs action. The action can store it as a variable for you which you can then use to do cool stuff like:

FPS or 3rd person controls
Throwing behaviours such as grenade throws
Pulling behaviours

It is stored as a Vector2 variable, so you can just use that however needed.
X axis should store left and right info, e.g. -1.0 is left and 1.0 is right.
Y axis should store up and down info, e.g. -1.0 is down and 1.0 is up.

I might add a way to check:

* the axis value and if touchpad is being pressed down perhaps stored as a bool, e.g. touchpad pressed down && left axis, which can also be used for certain kinds of games like 2.5 platformer games etc.

Will look more in to that tomorrow. But for now I've updated the action on Github and you can get it here: https://raw.githubusercontent.com/HendrikZA/general-playmaker/master/oculus%20go%20and%20gear%20vr/OculusGoButtonDown.cs
« Last Edit: January 28, 2019, 06:26:17 AM by HendrikB »

HendrikB

  • Playmaker Newbie
  • *
  • Posts: 37
  • In love with Playmaker
    • View Profile
Re: Oculus Go and Gear VR Controller Actions
« Reply #7 on: December 30, 2018, 06:25:40 PM »
I have now added the ability to check if the touchpad button is being pressed down and in what direction. I have also added the ability for you to set the sensitivity (offset) of the direction before it registers as a press.

For example, it defaults to 50% for all directions (and can be changed for any direction as needed using a sensitivity setting as needed). So if you press at least 50% upward or more from centre of the touchpad, it will count as an upward press.

I've already had a lot of fun testing this and it works great. I want to see if I can add the ability to check if the button is being held down for longer periods of time, e.g. the ability to hold down to the left to run to the left.

But for now I have updated the action on Github, please feel free to download it and play with it. I hope it helps with your next project :)

Download it here: https://raw.githubusercontent.com/HendrikZA/general-playmaker/master/oculus%20go%20and%20gear%20vr/OculusGoButtonDown.cs
« Last Edit: January 28, 2019, 06:26:37 AM by HendrikB »

HendrikB

  • Playmaker Newbie
  • *
  • Posts: 37
  • In love with Playmaker
    • View Profile
Re: Oculus Go and Gear VR Controller Actions
« Reply #8 on: December 30, 2018, 06:28:21 PM »
Here's a screen shot of what the action looks like so far  8)

edufurla

  • Playmaker Newbie
  • *
  • Posts: 42
    • View Profile
Re: Oculus Go and Gear VR Controller Actions
« Reply #9 on: December 31, 2018, 04:02:12 AM »
Fantastic! I am looking forward to try it. :)

HendrikB

  • Playmaker Newbie
  • *
  • Posts: 37
  • In love with Playmaker
    • View Profile
Re: Oculus Go and Gear VR Controller Actions
« Reply #10 on: December 31, 2018, 11:54:21 AM »
Fantastic! I am looking forward to try it. :)

Awesome hope it helps you :) I've been using it today for a new project I am working on and its made it a breeze compared to how I used to do it :)

HendrikB

  • Playmaker Newbie
  • *
  • Posts: 37
  • In love with Playmaker
    • View Profile
Re: Oculus Go and Gear VR Controller Actions
« Reply #11 on: December 31, 2018, 01:43:31 PM »
Added the ability to check for diagonal presses out the box. You can use the touchpadAxis value to do it manually yourself, but I just added some extra events in case you want to use those to make life easier.

Also added the ability to check if capacitive surface on touchpad is touched, but not pressed. Useful for certain types of movement.

You can adjust the sensitivity for all those as well, so how far the finger should travel on the touchpad before registering as up, down, right and left etc.

PS: In the screen shot below, you can see the set up I currently am using for a 3D side scroller/runner game. It will work great for 2.5 side scroller games too. As you can see you can leave events blank that you don't need, so its super useful to just pop this action on any state where you need to check for touch events for Gear VR and Oculus Go.

Hope it's useful to ya all. Happy 2019 folks! Hope you make awesome successful games this year :)
« Last Edit: December 31, 2018, 01:46:14 PM by HendrikB »

HendrikB

  • Playmaker Newbie
  • *
  • Posts: 37
  • In love with Playmaker
    • View Profile
Re: Oculus Go and Gear VR Controller Actions
« Reply #12 on: January 04, 2019, 12:20:16 AM »
If anyone prefers to have smaller actions instead of one large one, please let me know and I can split up the different sections of my current OculusGoButtonDown action into smaller actions.

If you are using the action for a game where you are interacting with objects in the scene using a reticle / laser pointer, and let's say you have a objects in the scene using this OculusGoButtonDown action, then of course, all of the events will fire if you press trigger, dpad or whatever. So a good tip for that is, use a global Playmaker variable that is set when your reticle / laser pointer highlights or hovers over a specific object (using object name or tag), and then let the object compare it's own name or tag to that global variable to let it decide if it should take an action or not when an event fires.

For example, let's say you have a door in the scene, and somewhere else in the scene you might have a light switch. These are two separate objects with their own FSMs potentially. There are a lot of ways to interact with these, but one method could be to have the OculusGoButtonDown action on each, both listening for the Trigger event to fire.

You could easily set up an FSM on your reticle in the scene to get the name or tag of the object you are hovering over, then set a global Playmaker variable called currentHoveredObject, then in each FSM for the door and light switch, when Trigger fires, simply compare the object's own name or tag to the global variable.

It's just one way to do it, and there are lots of different ways, but it's just an example that might help you if you are starting out with your first Gear VR or Oculus Go Playmaker project. You could also just have a separate empty game object in your scene, for example GM_Controller, then add an FSM to it to control all input related actions (so you just use one OculusGoButtonDown action), and do a bunch of comparisons to see what kind of object is being interacted with, and send a global event to that object when trigger is pressed etc. That is better for larger projects when you want to interact with prefabs and so on.

I hope it helps :) Feel free to PM if you have questions, I'll try my best to help. I can also write custom actions for Oculus Go / Gear VR, so let me know if there is anything specific that you would like me to create.

I'm currently working on two Oculus Go / Gear VR projects, both using my OculusGoButtonDown action, and so far, it is working perfectly. Of course it is also simple to integrate it with any other plugins on the asset store because all my action uses is the standard OVRInput API from Oculus, so it works out the box, assuming you have imported Oculus Utilities for Unity, which you should :)
« Last Edit: January 28, 2019, 06:28:11 AM by HendrikB »

edufurla

  • Playmaker Newbie
  • *
  • Posts: 42
    • View Profile
Re: Oculus Go and Gear VR Controller Actions
« Reply #13 on: January 04, 2019, 03:30:57 AM »
Hi Hendrik.
I am working in an Oculus Go / Gear VR project using your plugin and is really good.
I just submitted to the store and they ask me to position the controller following the hand setup (left or right hand).
Is it possible to make an action that gives the hand choice? Maybe a bool variable that is true when is in the right-hand mode.
Thank you for your great work. :)

HendrikB

  • Playmaker Newbie
  • *
  • Posts: 37
  • In love with Playmaker
    • View Profile
Re: Oculus Go and Gear VR Controller Actions
« Reply #14 on: January 04, 2019, 06:14:17 AM »
Hi Hendrik.
I am working in an Oculus Go / Gear VR project using your plugin and is really good.
I just submitted to the store and they ask me to position the controller following the hand setup (left or right hand).
Is it possible to make an action that gives the hand choice? Maybe a bool variable that is true when is in the right-hand mode.
Thank you for your great work. :)

Hey edufurla,

No problem, glad it has helped you :)

Sure, I'm writing a custom action for you right now that will check:

Left-handed controller detected
Right-handed controller detected
HMD only detected

For each you can choose to either save it as a bool to use as you wish, or you can also fire off an event, or both, depending on your needs. I'll upload it to Github later and paste the link here for everyone to use.