Search Unity

Question Read input from InputAction variable

Discussion in 'Input System' started by AlphaLulz, Nov 5, 2022.

  1. AlphaLulz

    AlphaLulz

    Joined:
    Sep 2, 2019
    Posts:
    51
    I'm trying to assign 1 single input action in a script and then check for the input in Update, but for some reason, whenever I press the key I assigned, it doesn't trigger. Here is an example of my code:
    Code (CSharp):
    1. public InputAction action;
    2.  
    3. void Update()
    4. {
    5.      if(action.triggered) Debug.Log("Input pressed");
    6. )
    It doesn't print the Debug.Log in the console even when I press the button that I assigned in the inspector. Is there something I'm missing?
     
  2. VirtualBoyBri

    VirtualBoyBri

    Joined:
    Jan 27, 2016
    Posts:
    6