Pausing Game While HMD Off Or In Oculus Menu

Hello, I’m making a game for the Oculus Rift. I need to fire a custom event when the HMD is removed and/or when the player hits the Oculus Menu button. This custom event will pause the game so that time isn’t passing while in the oculus menu and/or headset is removed from the player’s head.

Does anyone know how this can be done? I’ve been searching for BP nodes that remotely resemble anything pertaining to these tasks and came up empty. I’ve also checked this site and others for answers to no avail.

Any help will be greatly appreciated,
Thank you!

After testing I found that this works for what I needed but you have to constantly parse it. I was hoping for an event to be fired when the HMD was removed but haven’t had any luck finding it. If anyone knows please reply. Thank you,

217140-vrfocus.jpg

1 Like

Maybe it’s to late, but here is solution

You can use the VRNotifications component to check if the user has removed their headset, as explained by st.shaeen.

But you can also use the “Get VR Focus State” to get the same result. On Windows 7 the “Get VR Focus State” node will also return false when the Oculus menu is up, but if you’re running on Windows 10 you’ll need to use the “Has System Overlay Present” node in order to trigger a pause when the Oculus menu is up.

Please note that these features will only work for the Oculus and not the Vive.

1 Like

Where I have to put this code? In the level? In the Pawn?

Put it in a blueprint that’s always running in your app and that only has one instance so there are no conflicts. If there are multiple levels, you probably don’t want it in the level blueprint for example. But one suggestion would be to have it in your game mode blueprint perhaps?

Thanks for the quick reply, but I’m newbie and still don’t understand.

I have multiple levels, so I’ll try to put it in the game mode.

But what I don’t understand is, this code, is recursive?
I have to launch it multiple times, or just at the beginning, as beginplay let it be understood?

It has to be put in an Event tick so that it continually checks whether or not the user is wearing the headset or is in the Oculus menu. Just make sure that the blueprint you are using is set to “Tickable when paused” so that you can trigger an unpause again when the user closes the Oculus menu or puts on the headset again. Just google “UE4 Tickable when paused” and you’ll find ways of doing this either on the blueprint itself or on a specific tick thread of your choice.

1 Like

Many Thanks, but what about the oculus menù button?

Use a branch node with the “Has System Overlay Present” node plugged in. Then you can put a pause on the true output and an unpause on the false output.

Many Thanks!
This is the result in my game mode.
It should be work. I hope, I’ll test later.

1 Like

This works great when HMD is off on not on the head. But Oculus menu button does not pause the game. Does anybody know how to fix that?

1 Like