I need want to make a two player splitscreen game. i dont know how to do this as the questions similar didnt cover the control assinments. Plus, i only have 1 camera for the car but i have 2 cars duplicated in the game. Please help in the simplest way possible! because im only like 12 but i made the track and everything.
5 Answers
5Here is a tutorial on how to do exactly what you want multiplayer car tutorial using unity car tutorial
@jjr2xl here it is
This is actually simpler than it might seem.
Regarding the controls, you will use the same scripts and the same prefabs for both cars, differentiating them by a simple variable of your choosing, that identifies the player, so that when you get to the ‘update’ function you check your ‘player’ variable to see which input keys are affecting the gameobject.
Regarding the split screen, this is as easy as adding another camera, since all cameras render at the same time, based on their “NORMALIZED VIEWPORT RECT”.
How would you set up the variable to differentiate the two players?
I’ve got two instances of the same prefab. But not sure how to set up a variable to define which is P1 and which is P2.
Cheers! ![]()
Yes, it is possible. You can do it the way I do it. Duplicate the Horizontal and Vertical inputs. Set one of them only to WASD, and the other only to arrow keys. Then, create two different move scripts for each character. Use one of the Horizontal Vertical inputs. Then, add the Player 1 Script to one of the cars. Then add the other to the second car. Here is a split screen tutorial:
Both good answer’s, @unity_WrGn-sVEm9JlNg is very simple and @roamcel also very simple and you can merge the two idea’s together. Make 2 controllers like *unity_WrGn-sVEm9JlNg * said 1 that controlls the car movements with WAS and D and the other exactly the same script just coppied and named PlayerController2 instead of PlayerController1 and put the if(Imput.GetKey(KeyCode.LeftArrow)) {} // for each of your buttons but instead of WAS or D use the Arrow Keys for example. Next Create 2 prefabs of the player, 1 has player 1 controller and the left camera, and the second Player2 Controller and right camera. think thats what the other two are trying to explain without writing the code for you.
Take a look at the car tutorial scripts. See if you can find where the inputs are. Then go to Edit>Project Settings>Input and map your alternative keys. Then copy and paste the script, but change the inputs.
– anon36094622