How can I avoid using event tick when I want to detect if the player is wearing a VR headset?

I’ve been playing with a demo where I want to have a VR headset plugged in to the machine, but have it as an optional pawn in the game.

I’ve been using the Get HMD Worn State node to detect whether or not the user is wearing the headset, and it gives me back the worn/not worn data that I need.

By running an event tick I’m able to check constantly whether or not the user is wearing the headset and then switch the player controllers but I’m told its not the best practice to use event ticks.

Using this method also cuts my movement speed in half on the first person mode which I can only assume is the engine dropping out on the player controller to confirm we still have control?

Could anyone provide me with some alternative suggestions for this issue? Thanks.

Use begin play to setTimerByEvent. Then you could check every 1 second instead of every tick.

​​​​Alternatively, use getHMDDevice on begin play. And maybe include a widget option so the user can manually set this.

I don’t want to sound off like I’m some expert, because most certainly, I’m a novice. Since Unreal does give developers the power to create custom events up front, rather than far down, Is it possible to create a custom event for a Headset’s state change where it fires off after detection?

If that’s not possible, could you not use Event Begin Play to execute and loop a delay of say 1 second to check the headset state? So, instead of checking every frame, it would check every second… I personally don’t like this approach because it feels like a hack.

Hi, thanks for the replies, I’ll look into this and report back.

  • I was considering putting a button in the demo to switch between but for I don’t want to over-complicate it for people playing, I personally feel its more intuitive to just switch on detection.

  • Is there any benefits to performance increasing the time between checks, perhaps to say like 3 seconds?

I don’t think it’s a burden to have the player pause the game to put on/take off the headset. If the player is going to take time to put on and remove a headset, it only makes sense that the game does not play while the player is not participating, so, I would put this on the player to pause/unpause. In normal games, does the game know when the joypad is put down? With that said, you can simply check on unpause whether or not the headset is on.

If you don’t like that, I would go with creating a custom event, or, test performance when using some delay or logic to test the headset state. Only testing will be able to tell you the performance drop. You could count the number of frames between a start time and an end time (though this is only one of many tests to perform) to see how much difference between every frame, once every X frames, once every X seconds is.