How to Make a Split-Screen Game in 5 Minutes

For this tutorial I am going to be using the Car scene that comes with the Standard Assets Example Project. With that project open, you can find the scene in Assets > Sample Scenes > Scenes > Car.unity.

First, duplicate the camera rig. For the original camera, in the Viewport Rect settings, set H to 0.5. On the duplicated camera, set Y to 0.5 and H to 0.5. Now you have created the split screen view.

You may notice that there is a log message in the console due alerting you that there are two audio listeners in the scene. There are a couple solutions on the Unity Asset Store for split screen audio. Alternatively, you could simply delete one of the audio listeners, or create an audio listener that interpolates the positions of the two cars.

Next you need to duplicate the car and position it and the duplicated camera beside the original car. In the Auto Cam script on the second camera rig, change the target from the original car to the duplicated one and ensure that Auto Target Player is unchecked on both Auto Cam scripts (the one on the original car camera rig, and the duplicated one).

You can also change the material on one of the cars to differentiate between the two. At this point your game should look something like this:

Screen Shot 2015-11-14 at 7.37.37 PM

In Edit > Project Settings > Input, create a couple new input axes by increasing the size value by two. Name the two axes Horizontal2 and Vertical2. For Horizontal2, set the negative button to ‘a’ and the positive button to ‘d’. For Vertical2, set the negative button to ’s’ and the positive button to ’w’. For both, set the Gravity and Sensitivity to 3 and check Snap. Then scroll up and in the original Horizontal and Vertical input axes, erase the values for the Alt Negative Button and Alt Positive Button.

Find the script titled CarUserControl.cs and duplicate it. Rename it to CarUserControl2.cs. You may get an error in your console but you can ignore it for now. Open CarUserControl2.cs. On line 8, there should be a public class called CarUserControl. The class name needs to be the same as the script name, so rename that CarUserControl2.

Screen Shot 2015-11-14 at 7.57.35 PM

Next, around line 23 of the same script, the variables ‘h’ and ‘v’ are defined by getting the Horizontal and Vertical axes. Those should both be renamed as you renamed them in the Input settings, Horizontal2 and Vertical2. Save the script and return to Unity.

Select the duplicated car and replace the CarUserControl script with the CarUserControl2 script. Boom. You now have awesome split screen multiplayer on your PC/Mac. Press play to test it out. One player can use WASD to drive, and the other player will use the arrow keys.