1

I am developing an android game where the main player is controlled using 2 ui joystick buttons. As Mouse X is assign to left click the player stats shooting when the screen is touched(or mouse is pressed while developing). So how can edit the following code or change left click to ui button.

Player shooting input

if ((CrossPlatformInputManager.GetAxisRaw("Mouse X") != 0 || CrossPlatformInputManager.GetAxisRaw("Mouse Y") != 0) && timer >= timeBetweenBullets)
        {
            // ... shoot the gun
            Shoot();
        }
Ved Sarkar
  • 347
  • 2
  • 8
  • 18
  • Use "Horizontal" and "Vertical" instead of "Mouse X" and "Mouse Y". – Programmer Jan 13 '18 at 23:05
  • no working. it is a canvas ui button !!! – Ved Sarkar Jan 13 '18 at 23:17
  • This is a joystick right? If so, simply use the Image component with `CrossPlatformInputManager`. See video linked in the duplicate for more info. If you still insist on using a Button then see [this](https://stackoverflow.com/questions/41391708/how-to-detect-click-touch-events-on-ui-and-gameobjects/41392130?s=1|0.0000#41392130). #2 shows how to detect click on a UI button. – Programmer Jan 13 '18 at 23:26
  • I am using [Simple Joystick plugin](https://github.com/tim-hub/Simple_Joystick_Unity). – Ved Sarkar Jan 13 '18 at 23:39

0 Answers0