Here are some highlights from the code in my test:
From the C++ Player Controller class (*.h):
public:
AMyPlayerController();
(*.cpp):
AMyPlayerController::AMyPlayerController()
{
bShowMouseCursor = true;
bEnableClickEvents = true;
bEnableMouseOverEvents = true;
}
From the (generated) C++ Game Mode (*.h):
public:
AUEA389222GameMode();
(*.cpp):
AUEA389222GameMode::AUEA389222GameMode()
{
PlayerControllerClass = AMyPlayerController::StaticClass();
}
From the C++ Pawn class (*.h):
public:
// ...
UFUNCTION()
void OnSelected();
(*.cpp):
// Sets default values
AMyPawn::AMyPawn()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
OnClicked.AddUniqueDynamic(this, &AMyPawn::OnSelected);
}
void AMyPawn::OnSelected()
{
UE_LOG(LogTemp, Warning, TEXT("Pawn selected"));
}