Managing input from two players in the same computer using the Xbox 360 controller.

Hello!

I’m working in a small project in which two players fight each other in the same computer.
For this, I have a class I made to handle all the input stuff from Unity (Called InputController), as it seems everywhere people say to not use Unity’s own InputManager.

I decided to adapt my InputController (which only read KeyInputs values, and worked kinda fine) to get also the movement from the joystick axis from one xbox controller. Basically, I’m reading Input.getAxis(“Horizontal”/“Vertical”) and interpreting a value different of zero as “joystick is being used”, only for the second player. When launching the game and moving the first tank, it seems that Axis as changes, player 2 moves too.

I’ve read that the way to solve this is creating two InputManagers and reading from each player its own InputManager (So when player one’s virtual axis changes, player two’s don’t), but also I’ve read that using InputManagers is not advisable.

So:

  • The only way to control two objects in game with both keyboard and joystick is using the not-recommended InputManager and declaring two of it?
  • What is exactly the virtual axises? a reference to any kind of transformation of an item linked with the InputManager?

Maybe try to have more than 2 joysticks for each player and duplicate them as is? I can’t think of anything else unless you plan to use the Network base class.

using UnityEngine;
using System.Collections;

class Main: MonoBehavior

{

public Network network = new Network();

void Update() {

// network.doSomething(some.Arguments, other.Arguments);

}

}