Search Unity

Actions with modifiers?

Discussion in 'Input System' started by jwvanderbeck, Oct 22, 2019.

  1. Tempus_G

    Tempus_G

    Joined:
    May 12, 2015
    Posts:
    53
    Any news on the button click modifier to move mouse ( or not move it ).
     
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Mouse delta and position can both be gated by a OneModifierComposite bound to a button.
     
  3. Tempus_G

    Tempus_G

    Joined:
    May 12, 2015
    Posts:
    53
    I installed this and tested it out. Works nicely. Thank you. But It seems to have an issue.
    rotate.png
    With the Rotate action, I have a gamepad and keyboard setup.
    But which ever one I use first for rotating the view, stops the other from working.
    So can not switch between them as you should be able to.

    EDIT - UPDATE:
    Just tried to publish and test, as sometimes it is the editor that plays up.....
    However, the build failed to work. I get errors in the build .
    Code (CSharp):
    1. InvalidOperationException while resolving binding 'Rotate:Vector2WithModifiers' in action map
    I don't have any problems if I delete the "Rotate" binding and use the standard "Look" binding instead.

    EDIT 2:
    If I set the "Rotate" action to "pass through", it works for my use case now.
    BUT only in editor.
    If I build, errors pop up as before, Clear the errors and continue playing.....
    Then nothing works!! Except for the "Rotate" action ?!?
     
    Last edited: Feb 5, 2022
  4. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Vector2WithModifier isn't registered early enough (or at all). This isn't part of the input package so can't say exactly where the problem is. Make sure it registers BeforeSceneLoad.

    Judging from the screenshot, should be possible to replace it with TwoModifiersComposite.
     
  5. Tempus_G

    Tempus_G

    Joined:
    May 12, 2015
    Posts:
    53
    All I get is a button and two modifiers as standard to choose from. Have I missed something?
    This is one of many variations I have tried.
    rotate2.png
     
  6. TRS6123

    TRS6123

    Joined:
    May 16, 2015
    Posts:
    246
    @Tempus_G I'm might need more information before I can help you.

    Changed my code to reflect this (I didn't explicitly specify BeforeSceneLoad)

    The reason I include my own InputComposite is to get around the limitation of modifiers ignoring InputProcessors. My custom implementation allows you to gate input by a button NOT being pressed, thereby making it possible to set up mutually exclusive actions that share a binding.
     
  7. Tempus_G

    Tempus_G

    Joined:
    May 12, 2015
    Posts:
    53
    Here is some info from the debugger on the build version.
    No idea if it will help.

    Code (CSharp):
    1. IndexOutOfRangeException: Index was outside the bounds of the array.
    2.   at UnityEngine.InputSystem.InputBindingResolver.AddActionMap (UnityEngine.InputSystem.InputActionMap map) [0x00529] in E:\Unity test new controller Project\Library\PackageCache\com.unity.inputsystem@1.0.2\InputSystem\Actions\InputBindingResolver.cs:365
    3. UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
    4. UnityEngine.DebugLogHandler:LogException(Exception, Object)
    5. UnityEngine.Logger:LogException(Exception, Object)
    6. UnityEngine.Debug:LogException(Exception)
    7. UnityEngine.InputSystem.InputBindingResolver:AddActionMap(InputActionMap) (at E:\Unity test new controller Project\Library\PackageCache\com.unity.inputsystem@1.0.2\InputSystem\Actions\InputBindingResolver.cs:402)
    8. UnityEngine.InputSystem.InputActionMap:ResolveBindings() (at E:\Unity test new controller Project\Library\PackageCache\com.unity.inputsystem@1.0.2\InputSystem\Actions\InputActionMap.cs:1110)
    9. UnityEngine.InputSystem.InputActionMap:ResolveBindingsIfNecessary() (at E:\Unity test new controller Project\Library\PackageCache\com.unity.inputsystem@1.0.2\InputSystem\Actions\InputActionMap.cs:1016)
    10. UnityEngine.InputSystem.InputActionMap:Enable() (at E:\Unity test new controller Project\Library\PackageCache\com.unity.inputsystem@1.0.2\InputSystem\Actions\InputActionMap.cs:544)
    11. UnityEngine.InputSystem.InputActionAsset:Enable() (at E:\Unity test new controller Project\Library\PackageCache\com.unity.inputsystem@1.0.2\InputSystem\Actions\InputActionAsset.cs:721)
    12. MyInputControls:Enable() (at E:\Unity test new controller Project\Assets\My Player Control Setups\MyInputControls.cs:731)
    13. InputController:OnEnable() (at E:\Unity test new controller Project\Assets\My Player Control Setups\InputController.cs:30)
    14.  
    15. (Filename: E:/Unity test new controller Project/Library/PackageCache/com.unity.inputsystem@1.0.2/InputSystem/Actions/InputBindingResolver.cs Line: 365)
    16.  
    17. IndexOutOfRangeException: Index was outside the bounds of the array.
    18.   at UnityEngine.InputSystem.InputBindingResolver.AddActionMap (UnityEngine.InputSystem.InputActionMap map) [0x00ae8] in E:\Unity test new controller Project\Library\PackageCache\com.unity.inputsystem@1.0.2\InputSystem\Actions\InputBindingResolver.cs:555
    19.   at UnityEngine.InputSystem.InputActionMap.ResolveBindings () [0x00158] in E:\Unity test new controller Project\Library\PackageCache\com.unity.inputsystem@1.0.2\InputSystem\Actions\InputActionMap.cs:1110
    20.   at UnityEngine.InputSystem.InputActionMap.ResolveBindingsIfNecessary () [0x00016] in E:\Unity test new controller Project\Library\PackageCache\com.unity.inputsystem@1.0.2\InputSystem\Actions\InputActionMap.cs:1016
    21.   at UnityEngine.InputSystem.InputActionMap.Enable () [0x00022] in E:\Unity test new controller Project\Library\PackageCache\com.unity.inputsystem@1.0.2\InputSystem\Actions\InputActionMap.cs:544
    22.   at UnityEngine.InputSystem.InputActionAsset.Enable () [0x0001a] in E:\Unity test new controller Project\Library\PackageCache\com.unity.inputsystem@1.0.2\InputSystem\Actions\InputActionAsset.cs:721
    23.   at MyInputControls.Enable () [0x00001] in E:\Unity test new controller Project\Assets\My Player Control Setups\MyInputControls.cs:731
    24.   at InputController.OnEnable () [0x00001] in E:\Unity test new controller Project\Assets\My Player Control Setups\InputController.cs:30
    25.  
    26. (Filename: E:/Unity test new controller Project/Library/PackageCache/com.unity.inputsystem@1.0.2/InputSystem/Actions/InputBindingResolver.cs Line: 555)
    27.  
    28.  
     
  8. TRS6123

    TRS6123

    Joined:
    May 16, 2015
    Posts:
    246
    Would it be possible for you to send me your Input Action Asset file?
     
  9. Tempus_G

    Tempus_G

    Joined:
    May 12, 2015
    Posts:
    53
    I am using Unity 2020.3.15f2 at the moment. (and just tested with 2020.3.22f1)
    Even if I use the standard "Look" action, I still have build issues.
    If I delete the "Rotate" action completely from the actions list, then all works again.
     

    Attached Files:

  10. TRS6123

    TRS6123

    Joined:
    May 16, 2015
    Posts:
    246
    There's something wrong with the shaders. What Render Pipeline are you using for the project?
     
  11. Tempus_G

    Tempus_G

    Joined:
    May 12, 2015
    Posts:
    53
    I am using URP.
    I started off with the URP demo. Created a new scene and imported the new asset TPC asset as well as the new input system. Then replaced all with my own scripts as I needed custom controls. But looked at the others as reference.
    Convoluted I know o_O
     
  12. TRS6123

    TRS6123

    Joined:
    May 16, 2015
    Posts:
    246
    The crazy thing is that I'm not having either of the issues you're describing. I'm able to switch seamlessly between Gamepad and Keyboard/Mouse schemes and I'm able to successfully make and play a build.
     
  13. TRS6123

    TRS6123

    Joined:
    May 16, 2015
    Posts:
    246
    @Tempus_G I noticed in your error message that you're not using the latest version of the Input System. Also, what version of the unity editor are you using?
     
  14. Tempus_G

    Tempus_G

    Joined:
    May 12, 2015
    Posts:
    53
    I uninstalled and reinstalled Microsoft Visual Studio Community 2019 - Version 16.11.9 as the new 2022 is not(from what I can see fully supported yet).
    I tested on Unity 2019.4.19 , 2020.3.15 and 2020.3.22
    The Package manager only shows Input system v1.0.2 as standard which is what I am using.
    I also thought that perhaps it was something on my PC, so compiled the test level and ran it on another PC.... same issue in play mode.
    It is like on build, your script is the only one that runs.:confused:

    EDIT:
    Set to preview packages and installed input system 1.3.0 . Same issue.... but now less responsive on the mouse rotate?!?
    New LOG file attached.
     

    Attached Files:

    Last edited: Feb 10, 2022
  15. Tempus_G

    Tempus_G

    Joined:
    May 12, 2015
    Posts:
    53
    @TRS6123 I have no idea why Your solution has not worked for me. Hope this can be resolved as it is a handy set of options you have made.
    As @Rene-Damm had said, it was possible to do it with the "one modifier" option. So I have now got it working. However it is not a "Verified" package in the package manager (I am now using the latest version available at this moment being 1.3.0 ). So I did not find it till I looked harder and tested it.
    I prefer to use packages that are as tested as possible to limit the headaches :D

    Thank you all for your help in this.
     
  16. TRS6123

    TRS6123

    Joined:
    May 16, 2015
    Posts:
    246
    @Tempus_G So I looked at my repository and found that the meta files were missing. Turns out I didn't have a Unity-formatted gitignore file. I updated my repo and can successfully add my package with the package manager (Window->Package Manager->+->Add package from git URL). Could you see if the updated repo works?
     
  17. TRS6123

    TRS6123

    Joined:
    May 16, 2015
    Posts:
    246
  18. Tempus_G

    Tempus_G

    Joined:
    May 12, 2015
    Posts:
    53
    Just downloaded and tested the update. ERROR'S
    Will not even run
    No reason why, as I set it up like I did before.
    error.jpg
     
  19. TRS6123

    TRS6123

    Joined:
    May 16, 2015
    Posts:
    246
    @Tempus_G Do you run into issues after following these steps:
    1. Start a fresh project (2019.4 or newer)
    2. Import Cinemachine, URP, and AginerianInput (should automatically import InputSystem as a dependency)
    3. Let Unity restart to enable the backends for the New Input System
    4. Create a URP asset
    5. Go to Project Settings/Graphics and set your SRP asset to the newly created URP asset
    6. Import OrbitAndMoveTest.unitypackage, excluding the entire AginerianInput-master folder
    7. Open your cam orbit and move scene, click Play in the editor, and verify that everything works
    8. Open BuildSettings and make sure you're building for Windows x86_64
    9. Click Build and Run and select your preferred destination folder
    10. Verify that you can successfully make and play the build