Split Screen Viewport Support in UMG

I made a HUD using UMG, but when I enter split screen mode only one HUD is drawn across the whole screen, rather than in each split screen. I’m adding the HUD to the Viewport in the PlayerController class. Is there a way to implement a split screen-compatible HUD using UMG?

That is not directly supported yet, as far as I know. I have implemented a workaround in C++ that basically includes the following steps:

Add blueprint library functions to register and unregister UMG UserWidgets to your project. Basically a single widget or a list of widgets per player. Whenever you add your UMG HUD to the viewport, also register it. Whenever you remove your UMG HUD, unregister it. You need to keep track of those widgets yourself since there is no way to get hold of them later in C++ - you only get references to the underlying Slate widgets.

Now subclass UGameViewportClient and override LayoutPlayers() and add code similar to what I posted below. This will update the anchors of the registered widgets to match the current splitscreen layout. I guess you need a Border widget or another container widget at the top of your UMG HUD for this to work since it will dynamically be resized and you want the rest of your HUD to stay within that container.

Marc

Super::LayoutPlayers();

	const TArray<ULocalPlayer*>& PlayerList = GEngine->GetGamePlayers( this );

	for( ULocalPlayer* localPlayer : PlayerList )
	{
		UUserWidget* userWidget = UGlobals::Get().GetSplitscreenWidget( localPlayer->ControllerId );

		if( userWidget != nullptr )
		{
			FVector2D viewportSize;

			localPlayer->ViewportClient->GetViewportSize( viewportSize );

			userWidget->SetAnchorsInViewport( FAnchors( localPlayer->Origin.X, localPlayer->Origin.Y, localPlayer->Origin.X + localPlayer->Size.X, localPlayer->Origin.Y + localPlayer->Size.Y ) );
		}
	}

As of Unreal Engine 4.6, UMG still does NOT support multiple player controllers / splitscreen viewports, as far as I’m aware. I’m unable to implement it into my game.
I would like to spread awareness, so developers work on this!