Search Unity

New Actions not found in new Input System

Discussion in 'Input System' started by SamirTheDev, Jan 22, 2022.

  1. SamirTheDev

    SamirTheDev

    Joined:
    Nov 20, 2019
    Posts:
    5
    Hello! Currently I am getting an error stating :
    error CS1061: 'PlayerControlsAsset.WeaponActions' does not contain a definition for 'ADS1' and no accessible extension method 'ADS1' accepting a first argument of type 'PlayerControlsAsset.WeaponActions' could be found (are you missing a using directive or an assembly reference?)

    In my case, PlayerControlsAsset is the new Input Action Asset, and the Weapon Actions is the weapon folder.
    upload_2022-1-22_12-40-24.png
    The error is only appearing on the new ADS Action, not on the others.

    Here is the line of code :
    Code (CSharp):
    1. private bool isAiming;
    2. public PlayerControlsAsset controls;
    3.  
    4.  
    5.     // Initiation \\
    6.     private void OnEnable()
    7.     {
    8.         controls.Enable();
    9.     }
    10.  
    11.     private void OnDisable()
    12.     {
    13.         controls.Disable();
    14.     }
    15.  
    16.     private void Awake()
    17.     {
    18.         controls = new PlayerControlsAsset();
    19.  
    20.         controls.Weapon.ADS1.performed += _ => isAiming = true;
    21.  
    22.         controls.Weapon.ADS1.canceled += _ => isAiming = false;
    23.  
    24.     }
    Also this is my first post, some advice for the future are always welcome. Thanks
     
  2. Putcho

    Putcho

    Joined:
    Jun 1, 2013
    Posts:
    246
    Last edited: Jan 22, 2022
  3. SamirTheDev

    SamirTheDev

    Joined:
    Nov 20, 2019
    Posts:
    5
    I actually haven't referenced the PlayerControlsAsset in the inspector, because it isn't there ( not visible in inspector). But I am pretty sure that I don't have to since all the other actions are working fine. I'll try doing that.
     
  4. SamirTheDev

    SamirTheDev

    Joined:
    Nov 20, 2019
    Posts:
    5
    Yeah it still doesn't work. I will look into it later.
     
  5. Putcho

    Putcho

    Joined:
    Jun 1, 2013
    Posts:
    246
    you had generate the c# class right. and you asset did it has auto-save on?, you can open PlayerControlsAsset script and check if "ADS1" also in there with the right name and everything
     
  6. SamirTheDev

    SamirTheDev

    Joined:
    Nov 20, 2019
    Posts:
    5
    I've regenerated the project files, but haven't checked if ADS is there. I'll look into it
     
  7. SamirTheDev

    SamirTheDev

    Joined:
    Nov 20, 2019
    Posts:
    5
    Yeah so It's working now for some reason. I haven't really done anything specific. It got fixed on it's own. But yeah thanks for the help
     
    Putcho likes this.
  8. JonnyMW

    JonnyMW

    Joined:
    May 19, 2023
    Posts:
    1
    Hello i am getting this problem aswell, has anyone found a solution for this? I have basically identical code and all my other inputs are working aswell, just for one week i haven´t been able to add new Inputs.
     
  9. SteenPetersen

    SteenPetersen

    Joined:
    Mar 13, 2016
    Posts:
    104
    If anyone lands on this, I fixed it the issue by making sure that in all my scenes I had the Event System and Input System UI Input Module set correctly:

    upload_2024-3-10_10-1-36.png

    I was having the issue because one of my scene had the wrong (default) Actions Asset set.