Hello !
I didn’t find the answer to that, so here is my question : Can I cast and store the pawn in his controller once for all ?
I’m using my Controller to handle player’s inputs, and the Pawn should NOT change during the game. At first, I was handling everything directly in the Pawn itself and it was working fine, but for training purposes, I’m willing to switch everything to the Controller.
So basically what I’m trying to do is to call the moving function that is inside the Pawn from the Controller. The following code works, but force me into casting the pawn for EVERY functions. Plus, this is going to be called everytimes the player try to move or rotate the camera. I tried to make a ACommander * variable in the .h of the Controller and set it like below in the constructor so it’s set once for all, but it doens’t seem to work.
void ACommanderController::Test()
{
auto pawn = Cast<ACommander>(this->GetPawn());
if (pawn)
{
pawn->TestFunction();
}
}
Any idea how I could cast+store the pawn once ? So I could write something like :
void ACommanderController::Test()
{
pawn->TestFunction();
}
Thanks !