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

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.