[4.9.1] How to get HMD orientation? [ Resolved ]

Hi, im trying to get the orientation quaternion inside my pawn’s tick function in C++, but I dont find any way to do it.

  • I tried to use GEngine->HMDDevice->get… but Visual Studio says that cant use pointer to incomplete class

I added to myProject.build.cs the module “HeadMountedDisplay”
I included in myPawn.cpp, both “Engine.h” and “IHeadMountedDisplay.h”
But it doesnt work.

Is there an API to acces that function easily from any class on the game?
When the function returns correct orientation?, is needed to play the game with VR preview mode?
When I play Standalone game, and then press Alt+Enter, the window goes freeze, only the VR preview mode works ok with my Oculus DK2

There is BP function library for HMD, you can access it like so:

#include "HeadMountedDisplayFunctionLibrary.h"
///....
FVector DeviceRotation,DevicePosition;
UHeadMountedDisplayFunctionLibrary::GetOrientationAndPosition(DeviceRotation,DevicePosition);

Thanks a lot lion! That worked, but two thinks I haved to change.

  • The include gives me an error, but I don’t needed it to get acces to the function.
  • DeviceRotation is FRotator instead of FVector

Awesome! glad to help!