Download

Error when second player joins multiplayer game

The error is as follows:

Assertion failed: InPlayerController->IsLocalPlayerController() [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/Engine/Private/LocalPlayer.cpp] [Line: 203]

I have been doing a lot of digging and haven’t found any areas where the owning function would be called. Going to the location has the following code:

void FLocalPlayerContext::SetPlayerController( const APlayerController* InPlayerController )
{
check( InPlayerController->IsLocalPlayerController() ); **<---- Line with the error**
LocalPlayer = CastChecked<ULocalPlayer>(InPlayerController->Player);
World = InPlayerController->GetWorld();
}

Although I understand what the line is checking for, I can’t understand why it is being called as soon as a second player joins. I figured a multiplayer session would know that the joining player is not local, thus, no need for this check.

I never call “SetPlayerController” in any of my own code, but I imagine it is called somewhere on UE4’s end. So the only place I found where its called is below:

FLocalPlayerContext::FLocalPlayerContext( const class APlayerController* InPlayerController )
{
SetPlayerController( InPlayerController );
}

But again, I don’t have any personal calls to this function either, so I’m guessing it’s on UE4’s end. This function has no calls that I could find, so I’m stuck. I’m sure it has something to do with multiplayer and the second player joining, and that player not being considered a localplayer, but I’m not sure why that check is being made in the first place.

Your player controller gets made in the login function in your game type file when you join the game, Check there. That is where it all starts.