How to use getMousePositiononViewport in Unreal Engine C++?

I created simple class, who implemented AActor. In this class i want get mouse position in game-dispaly. I know, that i must included ‘Blueprint/WidgetLayoutLibrary.h’ in *.cpp-file and in method ‘Tick’ write the following:

FVector2D mousePosition = UWidgetLayoutLibrary::GetMousePositionOnViewport(GetWorld());

so that every tick to get mouse position… BUT!!! I get an error:

Worlds_constantes.cpp.obj : error LNK2019: ??뫪? ?? ??ࠧ??襭??? ???譨? ᨬ??? "__declspec(dllimport) public: static struct FVector2D __cdecl UWidgetLayoutLibrary::GetMousePositionOnViewport(class UObject *)" (__imp_?GetMousePositionOnViewport@UWidgetLayoutLibrary@@SA?AUFVector2D@@PEAVUObject@@@Z) ? ?㭪樨 "public: virtual void __cdecl AWorlds_constantes::Tick(float)" (?Tick@AWorlds_constantes@@UEAAXM@Z).
 C:\Users\user\Documents\Unreal Projects\Project_name\Binaries\Win64\UE4Editor-Project_name-6913.dll : fatal error LNK1120: ??ࠧ??襭??? ???譨? ??????⮢: 1

What to do? How to fix?


Hello! Just checkout APlayerController | Unreal Engine Documentation

  • GetMousePosition

also there are lots of other stuff there:

  • DeprojectMousePositionToWorld
  • DeprojectScreenPositionToWorld
  • GetHitResultAtScreenPosition
  • GetHitResultUnderCursor