Local Player is null when i'm in multiplayer playmode

Hello ! I wanted to make my prototype multiplayer, so i tried launching it in mutliplayer playmode to see what happends, and i figured out that GetLocalPlayer was returning a nullptr in my player controller, and i can’t find why anywhere on internet… (I use this function to get the Enhanced Input Local Player Subsystem).
If you have any idea on how to fix this i’d be very happy !

image

void ASkirmishPlayerControllerBase::OnPossess(APawn* aPawn)
{
	Super::OnPossess(aPawn);

	ControlledPlayer = Cast<ASkirmishPlayerClass>(aPawn);

	EnhancedInputs = Cast<UEnhancedInputComponent>(InputComponent);



	if(GetLocalPlayer() != nullptr)
	{

		UEnhancedInputLocalPlayerSubsystem* InputSystem = GetLocalPlayer()->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>();
		

		InputSystem->ClearAllMappings();
		InputSystem->AddMappingContext(PlayerMappingContext, 0);

		if (IAMove)
			EnhancedInputs->BindAction(IAMove, ETriggerEvent::Triggered, this,
				&ASkirmishPlayerControllerBase::MovementHandling);
		if (IALook)
			EnhancedInputs->BindAction(IALook, ETriggerEvent::Triggered, this,
				&ASkirmishPlayerControllerBase::LookingHandling);
		if (IAJump)
		{
			EnhancedInputs->BindAction(IAJump, ETriggerEvent::Triggered, this,
				&ASkirmishPlayerControllerBase::JumpTrigger);

			EnhancedInputs->BindAction(IAJump, ETriggerEvent::Completed, this,
				&ASkirmishPlayerControllerBase::JumpComplete);
		}
		if (IAGrab)
		{
			EnhancedInputs->BindAction(IAGrab, ETriggerEvent::Triggered, this,
				&ASkirmishPlayerControllerBase::GrabObject);

			EnhancedInputs->BindAction(IAGrab, ETriggerEvent::Completed, this,
				&ASkirmishPlayerControllerBase::ReleaseObject);
		}

	}


}

nvm I fixed the issue, there was a DOREPLIFETIME_CONDITION_NOTIFY() macro for a UPROPERTY that I forgot to put “Replicated” in, fixing that made the clients have a LocalPlayer again

hey did ya find a way to fix that??

1 Like

I happen to have a similar issue to OP in that when a client joins the input bindings arent setup becuase the Local Player is null, is this how you got the local player to not be null

where are you setting it up?

sometimes its a replication issue so a delay will ‘fix’ it but you should find a more reliable way