How do I remove a split-screen player?

I’m trying to implement a multiplayer mode with splitscreen. The menu only contains 1 menu pawn. When the player presses the “Multiplayer” button, a new map is loaded and on begin play I call “Create Player” three times.

Everything works great, but when I return to the main menu by hitting escape and opening that map, the screen is still split with 4 player controllers active. I’ve tried destroying the extra controllers, un-possessing each of them, and trying to call “Quit Game” on each, none of these work and calling quit game crashes the editor.

How can I remove or destroy these players?

Destroying the extra controllers?
Also in most cases returning to the main menu and then typing debugremoveplayer 3, then debugremoveplayer 2, then debugremoveplayer 1 in that order can fix the issue and restore it back to one player. When it comes down to “Quitting” depending on if that means quitting the session or the game itself, it shouldn’t be used on players 2 3 and 4.

If that suggestion doesn’t work, you may have to add a extra bit of code to your “multiplayer” code, such as telling the game to remove the three players upon the first player leaving that session.

Sorry for the late response but I figured it out - with help from the ShooterGame example. At the time - it had to be done in C++ it seems.

void AMultiplayerGameMode::RemoveSplitscreenPlayers()
	const int MaxSplitScreenPlayers = 4;
	ULocalPlayer* PlayersToRemove[MaxSplitScreenPlayers];
	int RemIndex = 0;

	for (FConstPlayerControllerIterator Iterator = GEngine->GameViewport->GetWorld()->GetPlayerControllerIterator(); Iterator; ++Iterator)
		// Remove only local split screen players
		APlayerController* Controller = *Iterator;
		if (Controller && Controller->IsLocalController() && !Controller->IsPrimaryPlayer())
			ULocalPlayer* ExPlayer = Cast<ULocalPlayer>(Controller->Player);
			if (ExPlayer)
				PlayersToRemove[RemIndex++] = ExPlayer;

	for (int i = 0; i < RemIndex; ++i)

Hi Tarwine,

I was wondering if since this point if you have found a way to do it within blueprint. If not then where would I put the code that you have posted above?

Thanks in advance!

Actually, I have a stupid way to solve this problem: there’s a blueprint node for “Execute Console Command” so I used it to execute “DebugRemovePlayer 1”. This removes the player exactly how it should. Using string concatenation and a for loop I’d imagine anyone who needs to remove x many local players from their game will be able to do so, but I can’t imagine this is good practice.

Since people who work on the engine read these sometimes, why have a “Create Player” blueprint node if you’re not going to have a corresponding “Remove Player” one? It seems awfully inconvenient.

The Console Command doesn’t work in a Shipping Build.

Thank you for posting this code. I was having a similar issue and this code allowed me to resolve it. Thanks again.

There is a non-coding way to do that too. Go to Edit-> Project Settings-> Project section-> Maps&Modes-> uncheck the Enable split screen box.
Hope this helps (worked for me)

Perfect! Thank you. The non-coding way is usually the best! Otherwise, you’re fighting the engine. Thanks for your response.