- Home /
StandardAssets (Mobile) Joystick activates Input Axis with mouse 0/1 attached (Android)
In my project I defined two Axes in the Input settings (Edit -> Project Settings -> Input), Fire 1 and Fire 2:
Positive Button of "Fire 1" is "mouse 0"
Positive Button of "Fire 2" is "mouse 1"
The corresponding update script of the player is as following:
void Update () {
if (Input.GetAxis("Fire 1") != 0)
spawnWeaponMain ();
if (Input.GetAxis("Fire 2") != 0)
spawnWeaponSecond ();
}
As input for my mobile Android device I'm using the default, unaltered Dual Joystick Prefab provided by Unity (v4.3.4) StandardAssets (Mobile).
When tapping on LeftJoystick or RightJoystick then
Input.GetAxis("Fire 1") != 0
is true.When tapping LeftJoystick and RightJoystick simultaneously,
Input.GetAxis("Fire 2") != 0
is true.
Both is unexpected behavior.(?)
Now when I remove mouse 0, mouse 1 from the Input Axis definition, Input.GetAxis("Fire 1") != 0
and Input.GetAxis("Fire 2") != 0
work as expected, both statements remain false when using the Joystick.
In the default Joystick.js I can't find where "mouse 0" and "mouse 1" are fired. Could someone point me in the right direction?
Answer by RoiDanton · May 27, 2014 at 01:07 PM
In fact this has nothing to do with the standard joystick script but with the fact, that on touch devices "mouse 0" is triggered on tap and "mouse 1" is triggered on multitouch tap.
Therefore
if (Input.GetMouseButtonDown(0)) // True for single tap.
if (Input.GetMouseButtonDown(1)) // True for multitouch tap.
Your answer
Follow this Question
Related Questions
Keyboard/Joystick Inputs Do Not Work until Mouse Clicked 0 Answers
my character settings are set for joystick how do i make em work with keyboard 0 Answers
Implementing a virtual joystick with mouse 1 Answer
How can I treat mouse movement as joystick input? 1 Answer
Use Gamepad right analog stick instead of mouse to control crosshair movement 3 Answers