Split-screen
Run two to four local players on one machine, each with a gamepad, a camera and a screen pane tiled by FSplitScreenLayout.
Split-screen puts two to four players on one machine. Each local player has a gamepad slot, a player controller, a camera and a pane of the screen. It needs no special render path: every camera already has a normalized viewport rectangle, and the runtime renders each camera into its region of the window. Split-screen only tiles those rectangles and routes each gamepad to its player.
Try it
Start the standalone game (MowoGame, or your packaged game executable) with --players=N, where N is 2 to 4. Values outside 1 to 4 are clamped.
MowoGame.exe --project=MyGame.mproject --players=2At startup the runtime creates one local player per count, with gamepad slot i driving player i. Each frame it assigns players to the scene's cameras in render order, recomputes the panes for the window size, and writes each pane onto its camera's viewport.
Author one camera per player. A scene with fewer cameras than players draws only the panes that have a camera; the rest stay empty. While more than one player is active, only the players' cameras draw: any other camera in the scene (a pawn's own camera, a stray one) is skipped instead of covering the window. Each pane renders through its own renderer view, with its own temporal history and motion blur; the panes after the first have no shadow atlas of their own.
Layouts
ESplitScreenLayout ESplitScreenLayout:
| Layout | Panes |
|---|---|
Single | One full-screen view |
Horizontal | Top and bottom. The two-player default. |
Vertical | Left and right |
Quad | A 2 by 2 grid. Order is top-left, top-right, bottom-left, bottom-right. |
Auto | Resolves from the player count: 1 is Single, 2 is Horizontal, 3 or 4 is Quad |
With three players in Quad, the first three cells are used. Adjacent panes share pixel edges exactly, with no gaps, even at odd resolutions.
- Player count
- Resolve layout
- Compute panes
- Copy to cameras
- Render each camera
The pieces
| Type | Role |
|---|---|
FViewportRect | One pane, both normalized (0 to 1, what a camera stores) and in pixels |
FSplitScreenLayout | Pure layout math. Compute(layout, playerCount, width, height, out) fills up to four rectangles. |
FLocalPlayer | A player index, the gamepad slot that drives it (-1 for keyboard and mouse), its controller, camera entity and pane |
FLocalPlayerManager | Owns the list, tiles the panes and maps gamepad slots to players |
FLocalPlayerManager holds no renderer or camera reference. It computes rectangles, and the caller copies them onto cameras FLocalPlayerManager.
Manage local players in code
#include "Core/Platform.h"
#include "Game/LocalPlayer.h"
#include "Game/SplitScreenLayout.h"
#include <cstdint>
static int32_t SetUpCouchCoop(Mowo::FLocalPlayerManager& players, uint32_t width, uint32_t height) {
players.Clear();
players.AddLocalPlayer(0);
players.AddLocalPlayer(1);
players.SetLayout(Mowo::ESplitScreenLayout::Vertical);
return players.RecomputeLayout(width, height);
}
static int32_t PlayerForGamepad(const Mowo::FLocalPlayerManager& players, int32_t gamepadSlot) {
return players.PlayerIndexForGamepad(gamepadSlot);
}AddLocalPlayer(gamepadIndex)assigns the next player index. It refuses more than four players, and adding a gamepad slot that already has an owner returns that owner instead of creating a duplicate FLocalPlayerManager::AddLocalPlayer.PlayerIndexForGamepad(slot)returns the owning player, or-1when the slot owns none. Use it to feed each player's controller from its own gamepad.RecomputeLayout(width, height)returns the number of panes written.
Local and online players
Split-screen is local only: several people share one machine and one world. Networked players on other machines are handled by sessions. FLocalPlayerManager does not register its players with a network session, so treat split-screen and online sessions as separate features.
Related
- Multiplayer overview for networked play.
- API:
FLocalPlayerManager,FSplitScreenLayout,ESplitScreenLayout.
Engine sources
This page describes behavior implemented in these files of the engine repository, checked against commit 5922e6e5e.
- Engine/Source/Runtime/Game/Public/Game/LocalPlayer.h
- Engine/Source/Runtime/Game/Public/Game/SplitScreenLayout.h
- Engine/Source/Runtime/GameHost/Public/GameHost/MGameEngine.h