Hello,
I am quite new at all this, so please be kind if i write stupid/wrong things.
I created a playercontroller class MyPC in my code.
From that, i created a BP class BP_MyPC in the editor.
Now back in my code i would like to get a reference to my ingame player controller so i can use methods from MyPC class.
I read a way to do this is the following:
playerController = GEngine->GetFirstLocalPlayerController(GWorld);
The problem is what type should i use for the variable playerController ?
I tried to cast:
MyPC *playerController = Cast<MyPC>( GEngine->GetFirstLocalPlayerController(GWorld) );
This compiles well but crashes at runtime, i guess because i am casting a child (BP_MyPC) to a parent (MyPC), which memory probably doesn’t like.
The c++ code doesn’t know about the blueprint class.
I tried to play around with the generatedclass taken from the following code in the gamemode:
static ConstructorHelpers::FObjectFinder<UBlueprint> PlayerControlerObjet(TEXT("Blueprint'/Game/player/BP_MyPC.BP_MyPC'"));
PlayerControllerClass = (UClass*)PlayerControlerObjet.Object->GeneratedClass;
But i went nowhere.
So how can i do this ?
Can i use PlayerControllerClass in some template or something ?
Thanks
Cedric