is it possible to map actions and axes in the player controller rather than in the character, and if yes can someone explain the process of doing it.
C++ or BP?
c++ would be of preference
Not only is it possible, it’s where it should be. Override SetupInputComponent in your player controller and do all the bindings there.
Eg. (pseudo):
void AMyPlayerController::SetupInputComponent()
{
Super::SetupInputComponent();
this->InputComponent->BindAction("Walk", EInputEvent::IE_Pressed, this, &AMyPlayerController::OnWalkStart);
this->InputComponent->BindAction("Walk", EInputEvent::IE_Released, this, &AMyPlayerController::OnWalkEnd);
}
void AMyPlayerController::OnWalkStart()
{
AMyCharacter* character = Cast<AMyCharacter>(this->GetCharacter());
if (character)
{
character->SetWalking(true);
}
}
void AMyPlayerController::OnWalkEnd()
{
AMyCharacter* character = Cast<AMyCharacter>(this->GetCharacter());
if (character)
{
character->SetWalking(false);
}
}
Thanks you a lot for the example