Any way to toggle the "Use Splitscreen" option during gameplay?

During actual gameplay we want to use splitscreen, but in a menu I want a single screen, four players added so that I can read their inputs for a “Ready Up” system.

I reckon I want to be able to uncheck/ check the “Use Splitscreen” option usually found in the DefaultEngine.ini, but is there a way to do that during runtime?

We need this to be done via blueprints, or by adding a static function to an already implemented plugin (C++).

if you need to toggle splitscreen in game, you will need to use c++.

GetWorld()->GetGameViewport()->SetDisableSplitscreenOverride(true);

if you want to expose it to blueprint, you can put it in a blueprint function library like this:

UABlueprintFunctionLibrary.h:

	UFUNCTION(BlueprintCallable, Category = "Viewport")
		static void DisableSplitScreen(AActor* Context, bool bDisable);

UABlueprintFunctionLibrary.CPP:

void UABlueprintFunctionLibrary::DisableSplitScreen(AActor* Context, bool bDisable)
{
	if (Context)
	{
		Context->GetWorld()->GetGameViewport()->SetDisableSplitscreenOverride(bDisable);
	}
}

How do I set the context that it shows up in? For example I can’t seem to locate the node from the gameinstance or gamemode

right click and uncheck ContextSensitive in the Action menu.

I had to reopen unreal to get the node to show up no worries. What would I connect to the target input though? I assume the player controllers would go in context right?

82357-splitscreenonode.png

you forgot the static Keyword in the function declaration of DisableSplitScreen(). static functions don’t have target parameters, and every function in your blueprint function library needs to be a static function.

and, as for the Context parameter, you can plug any existing actor into that node, because it just uses the actor to know which world we want to enable split screen in. so the player controller will work fine as a context.

any time you want to use GetWorld(), from within a static function, you will need to pass a context actor into that function, so it knows what world you are trying to get.

Thanks so much!