Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 Jun 22
sparklines
Close Help
  • 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
0
Question by stoven91 · Jul 19, 2015 at 06:56 PM · inputmultiplayerplugin

How do you correctly setup multiplayer using InControl?

If you have a minute, in a bit of a jam getting InControl working simultaneously with two controllers.

This is what I have working right now, but it only takes one controller at a time... (in the update method)

 InputDevice gamePad = InputManager.ActiveDevice;
     int playerNum = InputManager.Devices.IndexOf (gamePad);
     if(playerNum != -1){
         GameObject curr = map.players[playerNum].gameObject;
         curr.transform.Rotate (Vector3.down, rotationModifier * Time.deltaTime * gamePad.RightStickX, Space.Self);

         curr.transform.Translate (Vector3.down * speedModifier * gamePad.LeftStickY, Space.World);
         curr.transform.Translate (Vector3.right * speedModifier * gamePad.LeftStickX, Space.World);
         
         playerNum = -1;
     }

Alternatively, this doesn't work at all haha...

 void Start () {
     //playerObjs = new GameObject[2];
     playerObjs [0] = map.players [0].GetComponent<GameObject>();
     playerObjs [1] = map.players [1].GetComponent<GameObject>();

 }
 
 // Update is called once per frame
 void Update () {

     if( InputManager.Devices.Count >= 1){

         playerObjs[0].transform.Rotate (Vector3.down, rotationModifier * Time.deltaTime * InputManager.Devices [0].RightStickX, Space.Self);
         playerObjs[0].transform.Translate (Vector3.down * speedModifier * InputManager.Devices [0].LeftStickY, Space.World);
         playerObjs[0].transform.Translate (Vector3.right * speedModifier * InputManager.Devices [0].LeftStickX, Space.World);

     }

     if( InputManager.Devices.Count >= 2 ){
     
         playerObjs[1].transform.Rotate (Vector3.down, rotationModifier * Time.deltaTime * InputManager.Devices[1].RightStickX, Space.Self);
         playerObjs[1].transform.Translate (Vector3.down * speedModifier * InputManager.Devices[1].LeftStickY, Space.World);
         playerObjs[1].transform.Translate (Vector3.right * speedModifier * InputManager.Devices[1].LeftStickX, Space.World);

    
              }

}

The second attempt seems more like how I intuitively expected things to work, but I'm not getting very far with it. What sort of setup have you used to get multiple controllers working?

Comment
Add comment · 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 tobiass · Jul 27, 2015 at 09:00 AM 0
Share

In the second snippet, you are checking the Devices.Count. Are you sure you mean to do that? It does not mean the input comes from the second device, does it?

0 Replies

· Add your reply
  • Sort: 

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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Multiple joystick input 2 Answers

how do i implement a date picker that is similar to the date picker from iphone/ipad 0 Answers

Is there a way to get precise input ? 1 Answer

Spawning objects in multiplayer game 1 Answer

NSEvents and Unity 0 Answers


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