Search Unity

My Input Action asset doesn't work, but if I let Player Input create it it will work

Discussion in 'Input System' started by Stephen1701, Apr 14, 2021.

  1. Stephen1701

    Stephen1701

    Joined:
    Mar 29, 2016
    Posts:
    132
    Hi all,

    Unity 2020.3.2f
    Input System 1.0.2

    I have the Player Input component attached to my player.
    Now, if I use the Create Actions... button to create the Input Action Asset, my script can then catch the OnMove message that gets sent whenever WASD or the arrow keys are used.

    If I create this asset myself with right click and New, then set up the Move and WASD exactly the same (both WASD are Composite 2D Vectors) then my script does not pick up OnMove when I press WASD or arrow keys. I even right click and Copy on the Move action inside the auto generated one, and copied it to my asset, but it still doesn't work.

    Am I missing something? Does letting the Player Input component create the asset do something extra that I'm missing?
    Thanks in advance

    upload_2021-4-14_7-43-48.png

    This is the auto generated Input Asset
    upload_2021-4-14_7-45-31.png
    And this is my own Input Asset I created with right click and New
    upload_2021-4-14_7-46-0.png
    upload_2021-4-14_7-47-31.png
     
  2. Holonet

    Holonet

    Joined:
    Aug 14, 2017
    Posts:
    84
    From your first screenshot, it looks like the first slot in the PlayerInput component there is empty. When you click Create Actions, it's probably going to automatically select that action asset and assign it to the PlayerInput component. If you create the actions asset, you would then need to drag that asset into that slot in the PlayerInput component.
     
    Stephen1701 likes this.
  3. Stephen1701

    Stephen1701

    Joined:
    Mar 29, 2016
    Posts:
    132
    Thanks for your reply.
    The reason the slot is empty in the first screenshot is because I took it out so that the Create Actions button would appear, it was just for illustrative purposes :) In both instances I have dragged the 2 different assets into that slot.
     
  4. Thuztor

    Thuztor

    Joined:
    Sep 16, 2017
    Posts:
    5
    You have attached the Player Input component to your player gameobject.
    Also the script, with the OnMove() method?
     
    Stephen1701 likes this.
  5. Holonet

    Holonet

    Joined:
    Aug 14, 2017
    Posts:
    84
    Also, you kept the same (Send Messages) behavior?
     
    Stephen1701 likes this.
  6. Stephen1701

    Stephen1701

    Joined:
    Mar 29, 2016
    Posts:
    132
    Yes.
    The only difference in the entire set up is that I have the input asset that unity created, that does work, I then swap it directly for the one I have which doesnt work. I even copied the Move controls from the working one to my one, so that I wouldn't have to change the OnMove code.
     
  7. Stephen1701

    Stephen1701

    Joined:
    Mar 29, 2016
    Posts:
    132
    I did yes. The code didn't change. I only changed what input asset I dragged into the Player Input component.

    I think its a bug because the Move controls are identical. Copied with right click from the working asset to my asset.
     
  8. Holonet

    Holonet

    Joined:
    Aug 14, 2017
    Posts:
    84
    Odd. I guess I would try Debug.Log("whatever") in your method that is supposed to be triggered. Just confirm it's not getting hit at all. If not, maybe just create a new project and just try it on a cube or something, copying only your script and see if that behavior follows it. If it still seems to behave that way, maybe share the dummy project on a Google docs link or something and maybe we can figure it out.
     
    Stephen1701 likes this.
  9. Stephen1701

    Stephen1701

    Joined:
    Mar 29, 2016
    Posts:
    132
    Yeah. the debug.log wasn't being hit, so the OnMove wasn't being called.
    Not to worry, the Unity auto created one is working so I'll just stick with that.
    Maybe if someone from Unity looks at this thread they can confirm if there is any difference in the 2 ways of creating the input asset.

    Thanks for helping.
     
  10. Stephen1701

    Stephen1701

    Joined:
    Mar 29, 2016
    Posts:
    132
    I've just had the exact same problem again with Unity 2021.2.7f1 and Input System 1.2.0.
    I wish I remembered I made this post before spending nearly 2 hours trying to find the fault.
    Does anybody at Unity know what is going on with this?
     
  11. eonyanov

    eonyanov

    Joined:
    Oct 6, 2014
    Posts:
    21
    hi, check this checkboxes after copy actions to your asset. In my case it was missed after copy.
    upload_2022-5-26_17-19-33.png

    And check name of KeyboardMouse scheme. By Default, it named "Keyboard&Mouse". But in StarterAssets it named "KeyboardMouse" and there is a dependency on this name in the code:
    upload_2022-5-26_17-49-26.png
    It took me a really long time to figure out why my circuit didn't work.
     
    Last edited: May 26, 2022