This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+8 votes

I'm trying to create a simple 2D split screen platformer, which supports 2 players that have each their own camera following them. I think I have to use multiple viewports with a shared world but have no idea how to set this up.

Could someone give a basic example on how this would be done ?

in Engine by (177 points)

5 Answers

+2 votes
Best answer

Good news its now possible to splitscreen in 2d!

(from facebook.com Godot Group page)

Juan Alpaca
September 14 at 2:01pm

User Faless (sorry man, no idea what your real name is) fixed Viewport to make it easier to do 2D split screen, so I copiend and added a couple lines of code to the platformer demo to make it split screen too. It's pretty straightforward.

You can get it from godot-demos repository, and you need latest Godot head.
by (548 points)
selected by

Thanks for the link.

Link broken.. any updated link?

I updated the godot 3 demo project (pull request) but there's also a full tutorial on how to do this in godot 3 at kidscancode's blog.

+1 vote

For 3D it looks like this:
1. Add panel element and place it and resize so it matches your desire
2. Add a 'Viewport' to panel as child
3. Add 'Camera' as child to the viewport

by (444 points)
+2 votes

To create a split screen you need 4 scenes.
Scene one is your game scene with the world and all game objects including the player objects.

The second scene you create is the view. At this scene you need a Node as root element. This root element need two Panels. At this Panels we draw the game. That's the reason why you must organize the position and size as the splits screen should look like.

The next step is to create two scenes. You need this scenes to connect your world with the view. The root node of this two scenes are a Viewport. The Viewport at the scenes has two Children. As the first children you add your game world and second children is a camera.

Now you must write a little script for the camera. At this script you say what object you want look with the camera. Scene one with viewport and camera one should look to player one.Scene two with viewport and camera two should look to player two.
Next you activate the current point at your cameras.

At the last step you go to your view scene and add at the Panel, which should show player one, the scene where the camera is focused at player one.
Now you make the same thing with the Panel which should draw the world around player two. Add to the Panel the scene where the camera is focused at player two.

If I have say clearly what I mean and you have all done correct, you should have a split screen. At the moment it is the easiest way to create split screen that I know.

by (28 points)

That's quite a good high level description of what you need to do to get a split screen setup working, but for the 'game scene' itself, I found that it's better to make it an autoloaded scene, than just add it to the scene with the player-n camera directly.

Otherwise you can end up with duplicates of game scene objects and data.

0 votes

I'm not sure when it's implemented but there is a plan for this.

https://trello.com/c/Bj3kaeQH/25-add-a-nice-api-to-make-2d-split-screen-easier

by (9,800 points)

I have seen this and I Hope this implementation comes very fast.

+2 votes

This has changed for 3.0.
The simplest Node setup to achieve this in 3D is as follows:

Root Node
|ViewportContainer New for 3.0
||Viewport
|||Camera
|ViewportContainer2
||Viewport
|||Camera

To make this functional, I had to set Stetch property on for both ViewportContainers.

This will work when the project is played. The ViewportContainers appeared black in the 2D editor view until Godot was closed and re-opened. Only then would it display properly when editing.

by (18 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.