Accessing blueprint C++ code...

I’m currently doing some work in VR and I want to move some blueprint stuff over to C++.
The blueprint is calling the C++ code in HeadMountedDisplayFunctionLibrary.
So I thought to include its header (with its functions being static) and use it as is:

#include "Kismet/HeadMountedDisplayFunctionLibrary.h"
UHeadMountedDisplayFunctionLibrary::GetPositionalTrackingCameraParameters( ... ); //some example call

However this would give me linker error LNK2019 because it does not know the definition of said functions.
I’ve seen people just including “Engine.h” & “Runtime/HeadMountedDisplay/Public/HeadMountedDisplay.h”,
adding “HeadMountedDisplay” to the PublicDependencyModuleNames in the build.cs file and just duplicating the source code.

This works, but doesn’t seem to be much of an elegant solution. If it’s already there why can’t I use it ?
Could anyone give me some advice on how to do this ? My C++ is a bit rusty and I’m still new to the unreal 4 programming side.

Ran into similar issues some days ago and after getting some help found out exactly what you wrote here. Include “Runtime/HeadMountedDisplay/Public/HeadMountedDisplay.h” into the cpp and “HeadMountedDisplay” into the build.cs. From what I gathered it’s just how the Unreal Build Tool works.

As far as I know, you can only include stuff from the engine that’s been exported with the ENGINE_API macro. See for example “UKismetMaterialLibrary::GetScalarParameterValue” which you can call from your code thanks to that macro. None of the functions in “UHeadMountedDisplayFunctionLibrary” have it.

Thanks for the info, will work around it for now then :slight_smile: