Playmaker Forum

PlayMaker Updates & Downloads => Share New Actions => Topic started by: HendrikB on September 11, 2018, 05:28:54 PM

Title: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on September 11, 2018, 05: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 (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.
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: WayneAdams on October 02, 2018, 07: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.
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: WayneAdams on October 06, 2018, 12:42:29 AM
FYI. I got these working by putting them in an existing category and so far they work like a charm. Well done. :)
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on December 30, 2018, 01:37:37 PM
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!
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on December 30, 2018, 06: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 :)
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on December 30, 2018, 06: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.
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on December 30, 2018, 07: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
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on December 30, 2018, 08: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
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on December 30, 2018, 08:28:21 PM
Here's a screen shot of what the action looks like so far  8)
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: edufurla on December 31, 2018, 06:02:12 AM
Fantastic! I am looking forward to try it. :)
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on December 31, 2018, 01:54:21 PM
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 :)
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on December 31, 2018, 03: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 :)
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on January 04, 2019, 02: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 :)
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: edufurla on January 04, 2019, 05: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. :)
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on January 04, 2019, 08: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.
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on January 04, 2019, 08:54:33 AM
Hi edufurla, I've written the custom action for you and it should work right out the box. I have not been able to test it as yet, but will do so in a few hours as I am currently out for the day.

Give it a test and let me know if any issues, here is the link: https://raw.githubusercontent.com/HendrikZA/general-playmaker/master/oculus%20go%20and%20gear%20vr/OculusGoInputSource.cs

It should appear in the Input category in your Action Browser, once you've added the script to your project.
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: edufurla on January 04, 2019, 10:45:48 AM
Awesome! :D :D
Thank you. I will wait for your post.
Thank you
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on January 04, 2019, 01:52:40 PM
Hey edufurla,

Yup it all works I just tested it :) The action can detect if controller is left or right, and also if no controllers are detected, it shows that HMD only is true, so one can assume it is a Gear VR without controllers for example.

Give it a go and hopefully Oculus will accept your published game, I wish you best of luck with your submission to Oculus :)
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: edufurla on January 06, 2019, 04:31:31 AM
Hi Hendrik.

It worked perfectly. :) :)
Thank you.
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on January 06, 2019, 05:57:19 PM
Hi Hendrik.

It worked perfectly. :) :)
Thank you.

Nice dude :)
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: WayneAdams on January 09, 2019, 05:06:19 PM
Awesome to see you working on this. Thanks so much!
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on January 09, 2019, 07:02:18 PM
Awesome to see you working on this. Thanks so much!

It's a pleasure Wayne :) I'm using these actions I created in my own projects I'm working on and they have made life much easier!

If I find any new or interesting things I can make actions for Gear VR / Oculus Go, I'll add those too. I'll build some actions as well for Oculus Quest closer to its launch. I think those use the standard Rift touch controller inputs so they should be relatively easy to make.
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: edufurla on January 11, 2019, 10:42:11 AM
Hi Hendrik.
Is it possible to make an action getting the sensor info from the Oculus Go or Gear VR? To know when someone removed the headset.
Thank you
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on January 11, 2019, 01:59:49 PM
Hi Hendrik.
Is it possible to make an action getting the sensor info from the Oculus Go or Gear VR? To know when someone removed the headset.
Thank you

Hey edufurla,

Sure no problem, I'll write this now and add to Github. Will let you know when it is available. Will make it so that:

Send event if headset removed
Send event if headset is back on user face
Store bool - true if headset removed

So you will be able to use the events, or just store the bool to use for your own FSMs.

Will have it available in next hour :)

Cheers,
Hendrik
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on January 11, 2019, 02:53:17 PM
Ok I've added an action for Gear VR and Oculus Go to check if the headset has been removed and when it is put back on.

Here is the action:

https://raw.githubusercontent.com/HendrikZA/general-playmaker/master/oculus%20go%20and%20gear%20vr/OculusGoHeadsetStatus.cs

I'll test it some time this weekend but it should work just fine :)

Cheers!
Hendrik
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on January 11, 2019, 03:08:04 PM
Ok I've added an action for Gear VR and Oculus Go to check if the headset has been removed and when it is put back on.

Here is the action:

https://raw.githubusercontent.com/HendrikZA/general-playmaker/master/oculus%20go%20and%20gear%20vr/GetHeadsetStatus.cs

I'll test it some time this weekend but it should work just fine :)

Cheers!
Hendrik

Hmm seems it has a compiler error in Unity. I'll investigate, test and re-upload. Will let you know :)
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on January 12, 2019, 07:12:03 AM
Hi edufurla, I'm working on this and testing it today. Encountering some small issues with this particular one, but it will be ready soon.

Also, I'm going to break down the larger OculusGoButtonDown.cs action into smaller pieces. The larger one will still be available for folks who prefer the larger action with everything on it, but I also understand that it takes up a lot of space in the Action Browser when "Preview" is enabled. So I'll have for example button presses in a separate action and the capacitive touch in a separate action just to begin with, which will make it much shorter.

I'm also experimenting with a controller rotation and positioning action, which although might not be that useful since most Gameobjects can just be parented to the right/left hand on the OVRCamera, it might still prove useful in some situations depending on your needs. Good to have it rather than not.

Will update later today or at the very latest tomorrow with this Headset off / on face action.
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on January 13, 2019, 01:46:10 PM
Ok here is a new action to check if the Headset is on or off the face. You can send an event, or simply store the bool value to use for your own purposes :)

https://raw.githubusercontent.com/HendrikZA/general-playmaker/master/oculus%20go%20and%20gear%20vr/OculusGoHeadsetStatus.cs
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on January 13, 2019, 02:40:04 PM
I've also added a small action that just gets the controller rotation and position on every update. You can play around with it to see if it can be useful for you. I would imagine that you can use it to do stuff like door handle turning, controlling guns in the scene, etc.

I have played with it a bit and it works well. I'd recommend using debug or setting a text value every frame with the rotation and/or position of the controller to see how the rotations change to see which angles would indicate pointing left, right, up, down etc.

https://raw.githubusercontent.com/HendrikZA/general-playmaker/master/oculus%20go%20and%20gear%20vr/OculusGoPhysics.cs

I was thinking to use it for a reload action, when player pulls remote up towards their body, pointing upward. But there's an easier way to do that. You just add a cube above the player's head, mesh turned off, and collider set to trigger. Then if you are using a raycast with a controller's laser pointer, you can check if it hit the cube above the head, and hook up a global event to that in an FSM. I just did that a little while ago and was able to trigger a reload event each time without any issues when the controller was pulled up towards the head.

Anyways, happy developing folks :)
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: edufurla on January 14, 2019, 07:49:46 AM
Hi Hendrik, - that was fast! :D
Thank you very much.
I will give a try with the new rotation action too. I have no projects to use it right now but can be very handy in the future.
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on January 24, 2019, 05:35:02 PM
Hi Hendrik, - that was fast! :D
Thank you very much.
I will give a try with the new rotation action too. I have no projects to use it right now but can be very handy in the future.

No problem :)

I've also updated the rotation and position script. I created a new and improved script that captures all the controller's "physics", which is the easiest way I can describe it. So I am getting its position, velocity, rotation, angular rotation, angular velocity and so on. This is super useful for anyone trying to create throwing actions, or even to calculate how much force was used in a sword slash for damage to an enemy, or just a simple fishing rod throw or grenade throw.

I've added it here on my Github account for everyone to use. Hope it helps :)

https://raw.githubusercontent.com/HendrikZA/general-playmaker/master/oculus%20go%20and%20gear%20vr/OculusGoPhysics.cs

Cheers,
Hendrik
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on January 25, 2019, 05:42:29 PM
Hi folks,

Here's another action for Oculus Go. This one's job is simple:


Again just a simple little action but I'm sure it will be useful to you. I've added sensitivity settings that you can use to tweak a bit as needed.

https://raw.githubusercontent.com/HendrikZA/general-playmaker/master/oculus%20go%20and%20gear%20vr/OculusGoRotationAndDirection.cs

I will update the Readme file on my Github soon to account for all the extra actions I've been adding. Also I will rename all the actions soon so it makes more sense what each does, so please excuse the naming for now :)

Cheers!
Hendrik
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on January 28, 2019, 08:34:52 AM
Hi Oculus Go / Gear VR & Playmaker fans :)

Ok I have posted an update right at the beginning of this post (page 1, first post), with all the Oculus Go / Gear VR actions I have created.

I split the OculusGoButtonDown.cs (previously known as GetVRButtonDown.cs) into lots of smaller actions to make FSM state coding more manageable.

I hope these actions help you to make awesome games. Combined with Playmaker, its so easy to make games for Oculus Go :)

Here is the link to all my latest Oculus Go / Gear VR actions:

https://github.com/HendrikZA/general-playmaker/tree/master/oculus%20go%20and%20gear%20vr
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: dt1000 on March 01, 2019, 12:31:08 AM
Very nice job!
Wish I'd found these at the start of my project, rather than the end.
Using them for swipe detection... saved me a day or so of work!
:D

Game will be complete soon!!!
(http://i64.tinypic.com/v6lzjd.jpg)

Cheers,
Dan
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: craigz on May 22, 2019, 01:16:31 PM
HendrikB! :D

Thank you so much for making all of these - I'm crazy impressed :D

Do you happen to know if most of these should work with the Oculus Quest? *fingers crossed*

best,
criagz
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on June 16, 2019, 01:03:49 PM
Very nice job!
Wish I'd found these at the start of my project, rather than the end.
Using them for swipe detection... saved me a day or so of work!
:D

Game will be complete soon!!!
(http://i64.tinypic.com/v6lzjd.jpg)

Cheers,
Dan

Hi Dan great job your game is looking really great :-) And I'm really glad that these have helped you with your development! I'm currently using them for a VR platformer/puzzle game and it's just so easy using these actions. Good luck with completing and publishing your game  8)
Title: Re: Oculus Go and Gear VR Controller Actions
Post by: HendrikB on June 16, 2019, 01:06:41 PM
HendrikB! :D

Thank you so much for making all of these - I'm crazy impressed :D

Do you happen to know if most of these should work with the Oculus Quest? *fingers crossed*

best,
criagz

Hi Craigz,

Thanks very much, I hope they help you with your projects :) I have been meaning to get Oculus Quest actions completed. I'm not sure if they would work out the box with the Quest just yet, but I will have a look at the documentation and see if I can modify these to work with Quest, and upload them as separate actions specific to the Quest.

I'll try get those out by the end of June with some luck, depending on how hard it will be :)