How are you supposed to setup movement for clients if there are no PlayerControllers on clients?

To setup Enhanced Movment Systems you need to reference the UEnhancedInputLocalPlayerSubsystem so that you can call something like:

if (playerController) {
	UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(playerController->GetLocalPlayer());

	GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::White, playerController->GetName() + " binding");


	if (Subsystem) {

		Subsystem->ClearAllMappings();

		Subsystem->AddMappingContext(malleableControls, baseControlsPriority);

	}

}

The problem is that this requires an APlayerController to be on the local game to do, but there are no APlayerControllers on clients ever. So naturally I was assuming that there was some sort of behind the scenes black magic that was happening where the subsystem would somehow replicate to the client and that way the callbacks for the UInputActions would call so the server could know to move the character. Otherwise the character would never move.

But nope, as I suspected, the input callbacks never call on clients, and thus clients never move. So leading back to my question: How are you supposed to setup input on clients if there are no APlayerControllers?

Hey,

So I think your a bit mistaken on the Player Controllers there. The Player Controller is only valid on the Owning Client and the Server, so you aren’t able to access other Client’s PlayerControllers but you can your own. The network compedium is a great resource for things like that - Multiplayer Network Compendium | An Unreal Engine Blog by Cedric Neukirchen

What you may be seeing however is this being null at certain points on the Client such as Begin Play as the Client has to wait to be Possessed and then Replicate that down to the Client. So if your looking to grab the Player Controller at the first point its valid then on the Pawn you want to look at the OnRep_Controller function;

1 Like

Its also worth adding that Subsystems aren’t replicated at all and the EnhancedInput Subsytem is a Local Player Subsystem and therefore should only really run logic on the Owning Clients not the Server.

So I think your a bit mistaken on the Player Controllers there. The Player Controller is only valid on the Owning Client and the Server…

I see. I was getting that from here:
https://forums.unrealengine.com/t/no-player-controller-on-client/406641/2

which I may have misinterpreted. Using OnRep_Controller(), GetController() is valid. Thank you for your help!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.