- Home /
different behaviour of axis using xbox360 controller
I tried moving a cube to the values of "Horizontal" and "Vertical", and it worked with the standard settings. But the movement seemed to be restricted by a circle, while key input is restricted by a square.
I then changed the settings in the "key axis" to accept controller input and deleted the preset "controller axis". The result was a square restriction.
My question is why? I don't see any setting that could have this effect.
Thanks for the help
P.S: I really didn't know how to put this in one sentence for the headline. Sorry for the mess
Here is the code I'm using to move the cube
void Update () {
transform.position = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);
}
Answer by Leosori · Jan 04, 2014 at 06:38 PM
It's a design choice. You have circle with radius = 1, so you are getting a vector with a max. length of 1 in all directions. If you push the stick into a 'corner' you will get a vector like (~0.7, ~0.7) which has the length 1.
There a some gamepads and joysticks who will report (1, 1) in a corner, so depending on your application you may need to check for that.
The reason you are seeing a different behavior, if you change the predefined keyboard axes to joystick input, is that the sensitivity setting is pushing the real value towards the target value of +/- 1. For joysticks the default value is 1, but for keyboard it is 3. So you reach +/- 1 already with one third of movement with your stick.
that would make sense to me as well, but that's not happening. both times I used my xbox 360 controller the one way i got (~0.7, ~0.7), the other I got (1,1). That's what got me confused.
Same controller -> different results
Sorry if this wasn't clear
ah, I skipped that part of your question. I just tested it myself and I can see the same behavior. The sensitivity setting is set to 3 for keyboard input and 1 for joysticks. It pushes the real value towards the target value. If you set it to 3, you can see that you reach +/- 1 with just a little movement of your stick, so you can still reach +/- 1 in the corners too.
I have added this part to my previous answer.
Your answer
Follow this Question
Related Questions
How do I use an Xbox controller axis other than the left thumbstick? 0 Answers
Multiple x360 controllers get wrong IDs assigned. 2 Answers
Can't get Triggers to Work [Solved] 1 Answer
GetButtonDown not responding to Xbox 360 Button presses 0 Answers
Please help me set up my inputs. Im pretty confused. 2 Answers