Member-only story
Make a 2D Split-Screen in Godot 4 [GDScript + C#]
A must-have for your next co-op racing game…
Wanna make a local multiplayer game where all your players get their own view? Godot doesn’t have built-in split-screen support, but setting it up is super simple with multiple viewports! Each player gets their own camera to render the 2D world, and we stack all renders side-by-side.
The essential trick here is to create multiple combos of SubViewportContainer and SubViewport nodes, one per player. In the first one, you’ll put your whole 2D scene, along with your first player and their camera. Then, in the other viewports, you’ll put your other players with their cameras (but DO NOT copy the 2D scene!):
Then, attach a script on your scene/game manager node. This script will take care of automatically “re-assigning” the 2D scene to the other viewports as well — don’t worry: this doesn’t duplicate it, but it will allow those other viewports to render it as well:
GDScript
# get 2D scene (= 2D world) to share
var world = $path/to/viewport1.find_world_2d()
# give it to render to the viewport of Player 2…
