Is it possible to define key bindings for each local player?
e.g. so that in a local multiplayer game each player can define his own mappings for his gamepad.
To define key bindings for each local Player, u will need to create your own UGameViewportClient derived class and ur own UPlayerController derived class. (My aproach is in C++, as the wiki says it is the only way to do this).
In your class derived from UGameViewportClient, add the code specified in the following link A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums wich tells u depending ur gamecontrollers case, the code to add.
Then, create a class derived from UPlayerController as i told you, there u need to override the SetupInputComponent to differentiate each binding for each player id.
Declare ir your UPlayerControllerOwnClass.h:
virtual void SetupInputComponent() override;
And then in ur .cpp file:
Super::SetupInputComponent();
int32 id = GetLocalPlayer()->GetControllerId();
if (id == 0)
{
InputComponent->BindAction("Run_P1", IE_Pressed, this, &AMasterController::Run);
}
else if( id == 1)
{
InputComponent->BindAction("Run_P2", IE_Pressed, this, &AMasterController::Run);
}
...
...
void AMasterController::Run()
{
//Cast to ur own pawn, actor or character class
auto pawn = Cast<APawnClass>(this->GetPawn());
if (pawn)
{
pawn->Run();
}
}
This will work if you DO NOT override the SetupInputComponent in your Character or pawn class that is handle by the Player.
So there isn’t an out-of-the-box way to do this. Thank you for the suggestions.