Hi!
Im trying to organize all my controller stuffs of my player inside a class named MyPlayerController which inherits from APlayerController …
MyPlayerController has some functions like “LookAt”, “GoTo”, and i want to add “MoveHorizontal” and “MoveVertical” functions too… this is just for organization purpose…
This works:
class AMyPlayer : public ACharacter{
public:
void MoveHorizontal(float a);
//the rest of the functions that are used for ACharacter...
}
//source
void AMyPlayer::SetupPlayerInputComponent(UInputComponent* pic){
check(pic);
pic->BindAxis("Hor", this, &AMyPlayer::MoveHorizontal);
}
void AMyPlayer::MoveHorizontal(float a){
//apply code for horizontal axis movement
}
but this does not:
class AMyPlayerController : public APlayerController{
private:
AMyPlayer* myPlayer {nullptr};
public:
void LookAt(AActor* targetActor);
void GoTo(AActor* targetActor);
void MoveHorizontal(float a); //moved here...
};
//source
void AMyPlayerController::BeginPlay(){
myPlayer = Cast<AMyPlayer>(GetPawn());
}
void AMyPlayerController::MoveHorizontal(float a){
//apply code for horizontal axis movement for myPlayer
}
//source from AMyPlayer
void AMyPlayer::BeginPlay(){
playerController = Cast<AMyPlayerController>(GetController());
}
void AMyPlayer::SetupPlayerInputComponent(UInputComponent* pic){
check(pic);
//binding to the new location... but not binding at all, my player is not moving
//with this...
pic->BindAxis("Hor", playerController, &AMyPlayerController::MoveHorizontal);
}
is there any logical explanation for this behavior?.. its looks like the axis binding is working only for the current local class… where being called from…
Thanks in advance.