- Home /
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:
only one gameObject(Player_1) moves.
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 Force$$anonymous$$ode, Because Force$$anonymous$$ode.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.
First, I would increase your dead value to something around 0.1 or 0.05 ish because joysticks rarely default back to 0 when you release them, rather they have some residual value as you saw earlier with 0.0107. I would also remove snap when using gamepads as it will feel weird to loose all acceleration immediateny when the stick is released.
Next I would do as sriram90 said and change the force to acceleration so see if that fixes things.
What kind of gamepad are you using? I know that most gamepads are supported but the axes and butons can differ from gamepad to gamepad.
Answer by TykoX64 · Mar 21, 2014 at 03:19 AM
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.
Your answer
Follow this Question
Related Questions
Custom Input manager problem 0 Answers
Input.GetAxisRaw 1 Answer
Change input axis values from code 2 Answers
Using Xbox gamepad triggers as keys instead of axis? 1 Answer
Mapping multiple controllers 1 Answer