Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Gamepad : buttons not recognized but the gamepad is

Discussion in 'Scripting' started by arthur3808, Nov 8, 2020.

  1. arthur3808

    arthur3808

    Joined:
    Nov 8, 2020
    Posts:
    4
    Hi,
    I'm trying to use my gamepad, but the buttons are not recognized when I press any of them, "allControls" shows that there are only the leftStick and rightStick available... the gamepad is recognized though :

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.InputSystem;
    5.  
    6. public class test : MonoBehaviour
    7. {
    8.     void d(object p)
    9.     {
    10.         UnityEngine.Debug.Log(p);
    11.     }
    12.     void Start()
    13.     {
    14.         d("all : "+ string.Join("\n", Gamepad.all));
    15.         d("name : " + string.Join("\n", Gamepad.current.allControls));
    16.         d("stick : " + Gamepad.current.xButton.IsPressed());
    17.     }
    18.  
    19.     // Update is called once per frame
    20.     void Update()
    21.     {
    22.  
    23.         if (Gamepad.current.buttonEast.IsPressed())
    24.             d("Pressed");
    25.     }
    26. }
    27.  
    all : DualShock4GamepadHID:/DualShock4GamepadHID
    name : Stick:/DualShock4GamepadHID/leftStick
    Stick:/DualShock4GamepadHID/rightStick
    stick : False​
     
  2. arthur3808

    arthur3808

    Joined:
    Nov 8, 2020
    Posts:
    4
    nobody?
     
  3. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    777
    Hi,
    Have you watched any tutorials?
    This one for example:
     
  4. arthur3808

    arthur3808

    Joined:
    Nov 8, 2020
    Posts:
    4
    Thank you!