To bind actions and axes in the character blueprint class, I may have multiple such character instances for each new APlayerController. Merely 1 Action Name (e.g. avoiding UseSkill_P1, UseSkill_P2, etc) is required for each character by adding the node in the Player Controller. However, for more functionality the same is required in cpp.

What I've tried:

When I bind actions and axes (delegates) in the APlayerController's SetupInputComponent (e.g: InputComponent->BindAction("Attack", IE_Pressed, this, &AMyController::DoSomething);, then spawn multiple players with UGameInstance::CreateLocalPlayer(index, err, true), the editor will crash on pressing Play in Editor (Alt+P).

The error thrown during runtime is: Access violation - code c0000005 (first/second chance not available) and referencing the line where the first ActionBind appeared, e.g: UE4Editor_MyProject!AMyController::SetupInputComponent() [d:\path\to\project\source\private\mycontroller.cpp:66]

A common solution can be found in this wiki post it seems. In short, overwrite GameViewportClient and set it as default, then within, overwrite InputAxis and InputKey and increment the player controller index for each input device (gamepad) used.

As mentioned previously, this would require the project to specify a unique Action Name for each player index e.g. Attack_P4.

There is also some confusion that needs to be cleared up.

  • An AController will not be created for each input device connected.
  • 1-viewport-multiplayer isn't supported as split-screen. (Weird naming, but good for search engines).
  • Spawning new Local Players is generally done in your override of AGameMode::BeginPlay. I made it up to the deriving BPs of my Game Mode to call CreatePlayers to create up to the set amount of players.
  • Setting Skip Assigning Gamepad to Player 1 will allow keyboard to be used for player 1.

Hopefully there are some common best practices to tackle this problem. Any suggestion is very much appreciated!

PS Here is the related unreal answers hub question.


1 Answer 1


I tried the template approach, where it overrides SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) in the ACharacter derived class, and then bind delegates by calling e.g: PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);

For some reason this reminded me to include Super::SetupInputComponent(); in my APlayerController::SetupInputComponent and the bindings started working. The editor wouldn't crash any longer.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .