Search Unity

Question Problem with controlling 2 joysticks at a same time. (mobile)

Discussion in 'Input System' started by infernkp, Dec 2, 2020.

  1. infernkp

    infernkp

    Joined:
    Nov 25, 2020
    Posts:
    21
    I want to use 2 joysticks for my android game, currently I can control only 1 at a time after building the app.
    I added this code to CustomDeviceUsages.cs

    Code (CSharp):
    1.         InputSystem.RegisterLayoutOverride(@"
    2.            {
    3.                ""name"" : ""GamepadPlayerUsageTags"",
    4.                ""extend"" : ""Gamepad"",
    5.                ""commonUsages"" : [
    6.                    ""p1_Left"", ""p1_Right""
    7.                ]
    8.            }
    9.        ");
    10.  
    Code (CSharp):
    1.     private Gamepad p1_Left;
    2.     private Gamepad p1_Right;
    3.   protected void OnEnable()
    4.     {
    5.         InputSystem.AddDeviceUsage(p1_Left, "p1_Left");
    6.         InputSystem.AddDeviceUsage(p1_Right, "p1_Right");
    7.  
    8.     }
    I set control paths to On-Screen Stick components accordingly but I am getting this error after running the game:

    Cannot find control with path '<Gamepad>{p1_left}/leftStick' on device of type 'Gamepad' referenced by component 'OnScreenStick'
    Cannot find control with path '<Gamepad>{p1_Right}/rightStick' on device of type 'Gamepad' referenced by component 'OnScreenStick'

    What am I doing wrong here?