Supporting head movement-based gestures for in-game actions

I’m currently developing a simple Cardboard-oriented game and wanted to implement some head movement into my gameplay so that I could hook up some actions to head nods (both up and down), head shakes (the “no-no” movement) or head tilts (like the character jumping when you tilt your head to the right). Is there any easy way of handling these? The only way I thought of would be to manually catch the direction at which the head turned at each frame and if for a given number of consecutive frames the movement happened in the given direction (for example, only up on the Y axis with minimal change in X for the up nod), then interpret this as a given gesture. This sounds pretty hard and time-consuming, though.

Is there any less cumbersome way of doing this? Maybe some plug-and-play solutions for supporting head movement-based events?

I would go with time based gestures, meaning that for example for head nods, you can have two boxes, one on top and one on the bottom, and have a line trace on the HMD.
As soon as the line trace overlap the top box, you can start a timer, and if within 0.5 seconds the line trace overlapped the bottom box, then the gesture is recognized as a head nod, otherwise it will reset the action.
Same thing for the head shake, but I assume that the experience does not also feature the user looking around constantly, so that the boxes on the left/right can be in the same spot…in case the user can look around, you need to integrate a setup where the boxes readjust themselves, like if the user rotate 90°, after 1.5 seconds you can readjust the position of the boxes, so that the head shakes can be detected.
For the head tilt, you can just get the HMD orientation and do also a time based event, compared to the HMD start orientation.

Hope this helps :wink: