Split the screen for multiplayer

I´m finishing a game development, but I have a new requirement, make it multiplayer (splitting the screen and running two instances)… There is a way to instance a scene at the same time, and render them in a different part of the screen? Or what is the best approach to achieve this?

Thanks in advance!

I will post here the same answer I gave you on StackExchange

If you want to make a local multiplayer with a split screen, the way to go is to have two cameras and change the rect viewport of them :

For vertical split screen : (x, y, width, height)

  • 1st camera : (0, 0, 0.5, 1) ► left
  • 2nd camera : (0.5, 0, 0.5, 1) ► right

For horizontal split screen : (x, y, width, height)

  • 1st camera : (0, 0.5, 1, 0.5) ► top
  • 2nd camera : (0, 0, 1, 0.5) ► bottom


No need to have two worlds. However, if you want the players to have their own GUI, you will have to take a look at culling masks

Unity - Scripting API: Camera.cullingMask

Place all the objects of the player 1 in a new layer (“Player1Layer”), all the objects of player 2 in another (“Player2Layer”), and make sure the camera of the player 1 does not have “Player2Layer” checked in its culling mask while the camera of the player 2 does not have “Player1Layer” checked in its culling mask.

IMPORTANT NOTE

It seems that additional configuration is required so as to show GUI to a specific player. I don’t really know why.

Each player must have their own :

  1. Main camera with :

    • Correct viewport rect
    • A Depth value set to 0
    • A culling mask to Everything, except Player1Layer and Player2Layer
  2. A second camera with :

    • Correct viewport rect
    • A Depth value set to 1
    • A culling mask to Player1Layer (or Player2Layer for 2nd player)
  3. A dedicated canvas with :

    • Render Mode set to Screen Space - Camera
    • The correct camera configured in #2

For the sake of simplicity, attach the two cameras of a given player to a unique parent, and move the parent so that the two cameras will follow. Maybe, you can keep the cameras #2 at (0, 0, 0). I haven’t tested.