# How do I remove a second splitscreen player?

**URL:** <https://forums.unrealengine.com/t/how-do-i-remove-a-second-splitscreen-player/300237>\
**Category:** Blueprint\
**Tags:** unreal-engine, splitscreen, remove, question, Blueprint\
**Created:** [December 1, 2014, 6:40am UTC](https://forums.unrealengine.com/t/how-do-i-remove-a-second-splitscreen-player/300237 "2014-12-01T06:40:44Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![WaveParadigm](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@WaveParadigm](https://forums.unrealengine.com/u/WaveParadigm)\
**Post date:** [December 1, 2014, 6:40am UTC](https://forums.unrealengine.com/t/how-do-i-remove-a-second-splitscreen-player/300237/1 "2014-12-01T06:40:44Z")

</div>

I have two player local splitscreen basically working; in the level blueprint of my 2 player map I use Create Player (Index 1) to create a second player. However, upon returning to the main level or other levels, the second player is still present, even though I only want a single player. The debug console command “DebugRemovePlayer 1” command works perfectly, but I see no way to call something like that in blueprint. Any help would be very appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![WaveParadigm](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@WaveParadigm](https://forums.unrealengine.com/u/WaveParadigm)\
**Post date:** [December 1, 2014, 6:58am UTC](https://forums.unrealengine.com/t/how-do-i-remove-a-second-splitscreen-player/300237/2 "2014-12-01T06:58:46Z")

</div>

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 I want to. 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. I’m leaving this as unresolved until someone comes with a less ugly solution.

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bcd0d281](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bcd0d281](https://forums.unrealengine.com/u/anonymous_user_bcd0d281)\
**Post date:** [January 1, 2015, 10:11pm UTC](https://forums.unrealengine.com/t/how-do-i-remove-a-second-splitscreen-player/300237/3 "2015-01-01T22:11:18Z")

</div>

I’ve successfully used the DebugRemovePlayer console command to remove players, but it doesn’t work in a Shipping Build (probably because the Console isn’t available in Shipping builds).

I really need to know how to remove created players, either in Blueprint or C++. So if anyone has any leads on how to do this, I’d really appreciate it. Thanks.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bcd0d281](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bcd0d281](https://forums.unrealengine.com/u/anonymous_user_bcd0d281)\
**Post date:** [January 2, 2015, 4:38am UTC](https://forums.unrealengine.com/t/how-do-i-remove-a-second-splitscreen-player/300237/4 "2015-01-02T04:38:35Z")

</div>

I was able to remove extra players with the following C++ method, which was originally posted in this Question: [How do I remove a split-screen player? - Multiplayer & Networking - Epic Developer Community Forums](https://answers.unrealengine.com/questions/55184/how-do-i-remove-a-split-screen-player.html)

What it does it checks for, and removes from the game, all local splitscreen players except the primary player. The easiest way to get this into Blueprint is to create a C++ class that is a subclass of Blueprint Function Library, and add this method to it:

```
void UBP_FuncLib::RemoveSplitscreenPlayers()
 {
     const int32 MaxSplitScreenPlayers = 4;
     ULocalPlayer* PlayersToRemove[MaxSplitScreenPlayers];
     int32 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;
                 Controller->PawnPendingDestroy(Controller->GetPawn());
             }
         }
     }
 
     for (int32 i = 0; i < RemIndex; ++i)
     {
         
         GEngine->GameViewport->RemovePlayer(PlayersToRemove[i]);
     }
     
 }

```

---

<div class="post-metadata">

**Author:** ![Eduard\_Gotwig\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Eduard\_Gotwig\_1](https://forums.unrealengine.com/u/Eduard_Gotwig_1)\
**Post date:** [February 11, 2015, 12:51pm UTC](https://forums.unrealengine.com/t/how-do-i-remove-a-second-splitscreen-player/300237/5 "2015-02-11T12:51:54Z")

</div>

Used deprecated functions, please take a look at this solution, but its as of now broken:

> **[Missing "RemovePlayer" node](https://forums.unrealengine.com/questions/171521/missing-removeplayer-node.html)**
>
> In C++, you are able to remove players via the gameInstance, but in Blueprint there is currently no node to do so. Check the answer section of a proposed fix for this of me. I hope to see this in Unreal Engine at some point. Cheers.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bcd0d281](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bcd0d281](https://forums.unrealengine.com/u/anonymous_user_bcd0d281)\
**Post date:** [February 11, 2015, 1:57pm UTC](https://forums.unrealengine.com/t/how-do-i-remove-a-second-splitscreen-player/300237/6 "2015-02-11T13:57:08Z")

</div>

In your answer, you say the code isn’t working. Have you resolved the issue?

---

<div class="post-metadata">

**Author:** ![Sir\_Quizalot](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sir\_Quizalot](https://forums.unrealengine.com/u/Sir_Quizalot)\
**Post date:** [April 26, 2015, 10:37pm UTC](https://forums.unrealengine.com/t/how-do-i-remove-a-second-splitscreen-player/300237/7 "2015-04-26T22:37:15Z")

</div>

Hi, How would I select a specific player instead removing all players. What C++ code would I need?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bcd0d281](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bcd0d281](https://forums.unrealengine.com/u/anonymous_user_bcd0d281)\
**Post date:** [April 26, 2015, 10:52pm UTC](https://forums.unrealengine.com/t/how-do-i-remove-a-second-splitscreen-player/300237/8 "2015-04-26T22:52:51Z")

</div>

I would imagine something like only running the for loop only for the indices of the players you want to remove; but I’m not entirely sure, as I’ve only ever removed everyone but the main player.

---

<div class="post-metadata">

**Author:** ![thevfxguy13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@thevfxguy13](https://forums.unrealengine.com/u/thevfxguy13)\
**Post date:** [May 15, 2015, 12:26am UTC](https://forums.unrealengine.com/t/how-do-i-remove-a-second-splitscreen-player/300237/9 "2015-05-15T00:26:33Z")

</div>

We are currently using 4.5 on a game and this definitely works. Thanks Jonathan!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bcd0d281](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bcd0d281](https://forums.unrealengine.com/u/anonymous_user_bcd0d281)\
**Post date:** [May 15, 2015, 5:28pm UTC](https://forums.unrealengine.com/t/how-do-i-remove-a-second-splitscreen-player/300237/10 "2015-05-15T17:28:31Z")

</div>

This code originally posted here that removes all players except the main player actually uses deprecated code.

As of 4.4, GameViewport::RemovePlayer was deprecated. So I updated the method to use the new RemoveLocalPlayer method in UGameInstance; here is the updated code; note the new UGameInstance\* argument passed in, and how it’s used in the last for loop:

.h file code:

```
// Removes local splitscreen players, with Player Index 1 to 3, from the game, leaving only the primary player
	UFUNCTION(BlueprintCallable, Category = "Multiplayer")
		static void RemoveLocalSplitscreenPlayersFromGame(UGameInstance* CurrentGameInstance);

```

.cpp file code:

```
void UBP_FuncLib::RemoveLocalSplitscreenPlayersFromGame(UGameInstance* CurrentGameInstance)
{
	const int32 MaxSplitScreenPlayers = 4;
	ULocalPlayer* PlayersToRemove[MaxSplitScreenPlayers];
	int32 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;
				Controller->PawnPendingDestroy(Controller->GetPawn());
			}
		}
	}

	for (int32 i = 0; i < RemIndex; ++i)
	{
		//GEngine->GameViewport->RemovePlayer(PlayersToRemove[i]); // GameViewport::RemovePlayer was Deprecated in 4.4
		CurrentGameInstance->RemoveLocalPlayer(PlayersToRemove[i]);
	}
}

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bcd0d281](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bcd0d281](https://forums.unrealengine.com/u/anonymous_user_bcd0d281)\
**Post date:** [May 15, 2015, 5:30pm UTC](https://forums.unrealengine.com/t/how-do-i-remove-a-second-splitscreen-player/300237/11 "2015-05-15T17:30:59Z")

</div>

Check out the new answer I posted for updated code to avoid using a deprecated method.

---

<div class="post-metadata">

**Author:** ![paradoc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@paradoc](https://forums.unrealengine.com/u/paradoc)\
**Post date:** [March 11, 2016, 11:17pm UTC](https://forums.unrealengine.com/t/how-do-i-remove-a-second-splitscreen-player/300237/12 "2016-03-11T23:17:18Z")

</div>

this worked perfectly, thanks!

---

<div class="post-metadata">

**Author:** ![reddeath777](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@reddeath777](https://forums.unrealengine.com/u/reddeath777)\
**Post date:** [September 10, 2016, 2:21am UTC](https://forums.unrealengine.com/t/how-do-i-remove-a-second-splitscreen-player/300237/13 "2016-09-10T02:21:43Z")

</div>

As of now (ver. 4.13), there is a blueprint node for Remove Player. Use it after Create Player to remove the player and split screen.

---

<div class="post-metadata">

**Author:** ![Inukshuk07](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Inukshuk07](https://forums.unrealengine.com/u/Inukshuk07)\
**Post date:** [February 18, 2017, 4:21pm UTC](https://forums.unrealengine.com/t/how-do-i-remove-a-second-splitscreen-player/300237/14 "2017-02-18T16:21:31Z")

</div>

Thank you kindly! Helped out perfectly!
