C++ in Unreal is still unclear for me. I’d like to show the mouse cursor at runtime in C++ and the code seems to be compiled but it doesn’t work in Unreal Editor.
In the default MyCharacter.h I added the code:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true")) class APlayerController* MyController;
And in the default MyCharacter.cpp I added (in the constructor) the code:
//I don't know if MyController = GetWorld()->GetFirstPlayerController(); //either this code should be MyController = CreateDefaultSubobject<APlayerController>(TEXT("MyController")); //or this one //they both can be compiled, but make the UE Editor crash MyController->bShowMouseCursor = true; MyController->bEnableClickEvents = true; MyController->bEnableMouseOverEvents = true;
The problem is that I’m not sure how I should get the character’s controller from my character.