Search Unity

Resolved [2020.1.8f1] PS4 R2 as button is not working

Discussion in 'Input System' started by MlleBun, Oct 13, 2020.

  1. MlleBun

    MlleBun

    Joined:
    Sep 19, 2017
    Posts:
    163
    Hi,
    I have a simple question to see why my mapping is not working. With the new Input System, I want for the same action to map the LMB (for PC) and R2 (for PS4).

    upload_2020-10-13_21-48-33.png

    I left the Properties of the action as Button
    upload_2020-10-13_21-49-2.png

    And here are the parameters of both inputs :
    Left Button
    upload_2020-10-13_21-49-53.png

    R2 [PS4 Controller]
    upload_2020-10-13_21-50-9.png

    Nothing fancy. I execute this code that works perfectly with the mouse but not the PS4.

    Code (CSharp):
    1. PlayerInputSystem inputSystem;
    2.  
    3. private void Awake()
    4.     {
    5.         inputSystem = new PlayerInputSystem();
    6.         inputSystem.Player.TestButton.performed += ctx => TestButtonMethod();
    7.     }
    8.  
    9.  
    10. private void TestButtonMethod()
    11.     {
    12.         Debug.Log("Test Button Method valid.");
    13.     }
    14.  
    15.  
    16. private void OnEnable()
    17.     {
    18.         inputSystem.Player.Enable();
    19.     }
    20.  
    21.     private void OnDisable()
    22.     {
    23.         inputSystem.Player.Disable();
    24.  
    25.     }
    So I tested with R1, R2, L1 and L2 with the same parameters but get no debug output. I know R2 might be a value from 0 to 1, but it seemed that it was possible to define it as a button ?
     
  2. MlleBun

    MlleBun

    Joined:
    Sep 19, 2017
    Posts:
    163
    What I really love about bug reporting in this forum is that just after hitting Post Reply, you change something in your project and just fix the bug yourself ! Might be a very good solution to fix all our issues.

    "You got an issue ? Just post a thread and problem's solved ! :confused:"

    Ok, for posterity, here is the fix in code (#feelingSilly)
    Code (CSharp):
    1. inputSystem.Player.TestButton.started += ctx => TestButtonMethod();
    2. // started instead of performed