- Home /
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?
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?
Your answer
Follow this Question
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