• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by jjr2xl · Sep 07, 2011 at 06:42 AM · multiplayerscreenracingsplit-screen

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.

Comment

People who like this

0 Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Muzz5 · Sep 07, 2011 at 07:25 AM 0
Share

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.

4 Replies

· Add your reply
  • Sort: 
avatar image

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! :)

Comment
Adam_is_learning_all_the_time
JoseSanPS

People who like this

2 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

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

Comment
Adam_is_learning_all_the_time
zereda-games

People who like this

2 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

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".

Comment
zereda-games

People who like this

1 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image nuckolls · May 23, 2017 at 09:04 PM 0
Share

how would you do it? I'm confused can someone give me both scripts of player 1 and 2

avatar image

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:

https://www.youtube.com/watch?v=yt867hlKD30

Comment
zereda-games

People who like this

1 Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image zereda-games · Feb 16, 2019 at 02:18 PM 0
Share

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.

avatar image zereda-games zereda-games · Feb 16, 2019 at 05:32 PM 0
Share

and @rodude123 answered while i was LOL. also good tutorial!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

NEED p2 car script 0 Answers

SmartFoxServer or any multiplayer system installation 0 Answers

Restricting Canvas navigation for each player 0 Answers

Duplicate a scene for split screen game 2 Answers

Split screen without two cameras in 2D versus game? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges