- Home /
How can i make a two player controls for 1 keyboard with the car tutorial cars? Also, how can i make a split screen for it?
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.
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.
Answer by muzboz · Jan 24, 2013 at 04:26 AM
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! :)
Answer by rodude123 · Sep 19, 2015 at 06:21 PM
Here is a tutorial on how to do exactly what you want multiplayer car tutorial using unity car tutorial
@jjr2xl here it is
Answer by roamcel · Sep 07, 2011 at 09:05 AM
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 do it? I'm confused can someone give me both scripts of player 1 and 2
Answer by unity_WrGn-sVEm9JlNg · Feb 16, 2019 at 12:44 PM
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. $$anonymous$$ake 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 ins$$anonymous$$d of PlayerController1 and put the if(Imput.Get$$anonymous$$ey($$anonymous$$eyCode.LeftArrow)) {} // for each of your buttons but ins$$anonymous$$d of WAS or D use the Arrow $$anonymous$$eys 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.
and @rodude123 answered while i was LOL. also good tutorial!
Your answer
Follow this Question
Related Questions
NEED p2 car script 0 Answers
Multiplayer (two people on 1 PC) 1 Answer
Local Multiplayer, Player Sign In c# 1 Answer
Smartfox Multiplayer Update problem 0 Answers
Two camera for Two PC-Screen 0 Answers