Weird Input Manager behaviour

alt textI’ve created a simple multiplayer game and now I’m trying to set up my two gamepads.
This is how my input manager looks like:

Axes

  • Name: Horizontal_P1
  • Type: Joystick
  • Axis: X axis
  • JoyNum: Joistick 1

  • Name: Vertical_P1
  • Type: Joystick Axis
  • Axis: Y axis
  • JoyNum: Joistick 1

  • Name: Horizontal_P2
  • Type: Joystick Axis
  • Axis: X axis
  • JoyNum: Joistick 2

  • Name: Vertical_P2
  • Type: Joystick Axis
  • Axis: Y axis
  • JoyNum: Joistick 2

Here’s a bit of my code from the Player_1 script:

void FixedUpdate()
	{
		float _moveHorizontal = Input.GetAxis ("Horizontal_P1");
		float _moveVertical = Input.GetAxis ("Vertical_P1");
		
		Vector3 _movement = new Vector3(_moveHorizontal, 0.0f, _moveVertical);
		
		rigidbody.AddForce (_movement * _movementSpeed, ForceMode.Force);
	}

All the player gameObjects have a similar script attached.

And here come the problems:

  1. only one gameObject(Player_1) moves.
  2. ONLY on the x axis (only left and
    right).

Please help.

Can you post some scripts, when you're tapping on joystick pad ?

Am not sure what's going on because of i dont have unity right now. Try to change your ForceMode, Because ForceMode.Force Adds continious force on rigidbody using mass. Try with acceleration force mode.

Can you post a screenshot of your input setup? The problem could be that deadzones and input types could be mismatched.

I ran a Debug.Log(_moveHorizontal) and Debug.Log(_moveVertical). For no apparent reason, the values are 0.0107 and 0.0107...even if I'm not touching the gamepad at all. The input manager is set up just as I wrote in my question, but I'm adding the screenshots anyway...

Is Unity such a f-ed up game engine??? Somebody help me!!! I'm really losing i it!

1 Answer

1

So the solution was to up the answer was to up the dead value for your gamepad input so that the smaller values were ignored since the gamepad joysticks almost never reset back to exact 0.

Second is to make sure what axis your gamepad is using, the default unity gamepad controls are set up for the Xbox 360 controller. The actual gamepad you are using may have funky button and axis setups. I’m not sure what the best way to find out exactly what buttons and axes do what in unity. If anyone knows a better way than just trying every possibility I’d love to know.