Hi, I’ve wanted to have my game support split screen for more than 4 players, but it has a hard code cap on 4, and when you remove that cap, there are still problems.
The only way I’ve found that does this is changing the engine source code, and game code a little bit.
I’m putting this here to make life easier for whoever wants to do this as well.
First, in your engine project, go to ViewportSplitScreen.h, and add another value to the ESplitScreenType enum, For this tutorial, we’ll add EightPlayer to it.
Then, go to the constructor of GameViewportClient.h, and notice this code.
SplitscreenInfo[ESplitScreenType::FourPlayer].PlayerData.Add(FPerPlayerSplitscreenData(0.5f, 0.5f, 0.0f, 0.0f));
SplitscreenInfo[ESplitScreenType::FourPlayer].PlayerData.Add(FPerPlayerSplitscreenData(0.5f, 0.5f, 0.5f, 0.0f));
SplitscreenInfo[ESplitScreenType::FourPlayer].PlayerData.Add(FPerPlayerSplitscreenData(0.5f, 0.5f, 0.0f, 0.5f));
SplitscreenInfo[ESplitScreenType::FourPlayer].PlayerData.Add(FPerPlayerSplitscreenData(0.5f, 0.5f, 0.5f, 0.5f));
This is the actual split of the split screen players on the screen. So you need to add one for your amount of players:
For example, this is one split that you could have for 8 players
//Top Row
SplitscreenInfo[ESplitScreenType::EightPlayer].PlayerData.Add(FPerPlayerSplitscreenData(0.25f, 0.5f, 0.0f, 0.0f));
SplitscreenInfo[ESplitScreenType::EightPlayer].PlayerData.Add(FPerPlayerSplitscreenData(0.25f, 0.5f, 0.25f, 0.0f));
SplitscreenInfo[ESplitScreenType::EightPlayer].PlayerData.Add(FPerPlayerSplitscreenData(0.25f, 0.5f, 0.50f, 0.0f));
SplitscreenInfo[ESplitScreenType::EightPlayer].PlayerData.Add(FPerPlayerSplitscreenData(0.25f, 0.5f, 0.75f, 0.0f));
//Bottom Row
SplitscreenInfo[ESplitScreenType::EightPlayer].PlayerData.Add(FPerPlayerSplitscreenData(0.25f, 0.5f, 0.0f, 0.5f));
SplitscreenInfo[ESplitScreenType::EightPlayer].PlayerData.Add(FPerPlayerSplitscreenData(0.25f, 0.5f, 0.25f, 0.5f));
SplitscreenInfo[ESplitScreenType::EightPlayer].PlayerData.Add(FPerPlayerSplitscreenData(0.25f, 0.5f, 0.50f, 0.5f));
SplitscreenInfo[ESplitScreenType::EightPlayer].PlayerData.Add(FPerPlayerSplitscreenData(0.25f, 0.5f, 0.75f, 0.5f));
Add those according to whatever split screen split you need.
Then, in the same constructor, find the line
MaxSplitscreenPlayers=4;
and set it to your maximum split screen players.
EDIT: forgot a step:
Now go to UGameViewportClient::UpdateActiveSplitscreenType() and add a case for your amount of players
For example, I would add
case 8:
SplitType = ESplitScreenType::EightPlayer;
break;
Now, there is one last thing you must do for it to not crash.
Go to IndirectLightingCache.cpp, to FIndirectLightingCache::UpdateCachePrimitivesInternal, and change line 498
TArray<uint32> SetBitIndices[4];
to
TArray<uint32> SetBitIndices[8];
or whatever you want your maximum split screen players to be, otherwise your engine will crash.
After that compile your engine and project, and it should work.