Forum rules - please read before posting.

AC compatibility with Unity's new Input System

2

Comments

  • The Movement Action expects a 2D composite - as this replaces the default Horizontal / Vertical inputs together.

  • 2D Composite is not listed as an option.

  • For some reason, that's just not appearing in mine.

  • Sorry, just realized the value was not set to vector 2. it was set to axis for some reason. It appears now. Thanks!

  • edited April 2021

    Bumped into this great post. About this code:
    https://adventure-creator.fandom.com/wiki/Input_System_integration

    Do I need to put it in every scene? Would it work if I make it 'dontdestroyonload' and only add to the title scene?

  • For a custom script to be persistent, you have a few options:

    1. As you say, call DontDestroyOnLoad and place it in your first scene
    2. Attach it to your AdventureCreator/Resources/PersistentEngine prefab, so that it automatically survives scene changes (but will need re-adding upon updating AC)
    3. (Recommended) Create an EventSystem prefab, attach the script to it as well, and assign it at the top of the Menu Manager. Just be aware that to retain AC's input functionality over Unity UI menus, use AC's own Optional Mouse Input Module instead of Unity's default Standalone Input Module.
  • For option 3, since there is already a EventSystem object in each scene created by Adventure Creator, do you mean I attach the InputSystemIntegration script onto it, and then drag it to Asset to make it a prefab?

    use AC's own Optional Mouse Input Module instead of Unity's default Standalone Input Module

    How may I set it to do this?

  • edited June 2021

    I also have no idea what to set to the Cursor Movement Action in the inspector if I want both the Mouse and Keyboard arrow keys to be able to control the cursor. Could you point me to the right direction?

  • do you mean I attach the InputSystemIntegration script onto it, and then drag it to Asset to make it a prefab?

    That should work, yes.

    what to set to the Cursor Movement Action in the inspector if I want both the Mouse and Keyboard arrow keys to be able to control the cursor.

    You'll want to create a Vector2 input in the Input window mapped to both the mouse and arrow keys. Mouse movement is named "Delta [Mouse]" in the bindings.

  • edited June 2021

    I fail to navigate the menus directly. About this:

    Just be aware that to retain AC's input functionality over Unity UI menus, use AC's own Optional Mouse Input Module instead of Unity's default Standalone Input Module.

    I have added this component to the EventSystem object:

    But it gives the error of:

    InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
    UnityEngine.Input.get_mousePosition () (at <2db13ba0d52343228aa9892c408fb49a>:0)
    UnityEngine.UI.MultipleDisplayUtilities.GetMousePositionRelativeToMainDisplayResolution () (at C:/Program Files/Unity2019.4/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/MultipleDisplayUtilities.cs:40)
    UnityEngine.EventSystems.BaseInput.get_mousePosition () (at C:/Program Files/Unity2019.4/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/InputModules/BaseInput.cs:75)
    UnityEngine.EventSystems.StandaloneInputModule.UpdateModule () (at C:/Program Files/Unity2019.4/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:183)
    UnityEngine.EventSystems.EventSystem.TickModules () (at C:/Program Files/Unity2019.4/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:331)
    UnityEngine.EventSystems.EventSystem.Update () (at C:/Program Files/Unity2019.4/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:344)

  • Can you give more detailed steps on how you're getting this error to appear? Without supplying an EventSystem prefab, the Optional Mouse Input Module is generated anyway by default. I may need to see your Settings Manager as well.

  • edited June 2021

    Btw my AC version is 1.72.4, Unity 2019.4.6f1

    I have an EventSystem prefab in the Menu manager:

    The EventSystem looks like this:


    p.s. I cannot navigate the menu directly either with or without the Optional Mouse Input Module attached or being active.

    The error of
    InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
    seems to comes from that the Optional Mouse Input Module script is using the old Unity Input system, but I have switched to the new Unity input package.

    My Setting Manager looks like this:




  • edited June 2021

    Can you give more detailed steps on how you're getting this error to appear?

    The error keeps appearing every frame when is game is run with the Optional Mouse Input Module attached to the EventSystem.

  • I cannot navigate the menu directly either with or without the Optional Mouse Input Module attached or being active.

    Were you able to do this before the new Input System package was installed? Menus need to be configured to allow for direct-navigation.

    The error keeps appearing every frame when is game is run with the Optional Mouse Input Module attached to the EventSystem.

    What about when no EventSystem prefab is assigned, and the Input System Integration script is placed elsewhere in the scene?

  • Were you able to do this before the new Input System package was installed? Menus need to be configured to allow for direct-navigation.

    Yes. It worked when using the old system. If I set Project Settings > Player > Other Settings > Active Input Handling to Both, it would still work. But it is not a long term solution, and difficult to support various controllers.

    But when using the New Input System, I can't navigate menus, nor use InteractionA to trigger the menu item.

    What about when no EventSystem prefab is assigned, and the Input System Integration script is placed elsewhere in the scene?

    I tried but no luck. Without assigned prefab, the auto-instantiated EventSystem with the Optional Mouse Input Module still gives the above error.

  • But when using the New Input System, I can't navigate menus, nor use InteractionA to trigger the menu item.

    Unity UI menus rely on the Submit input to invoke interactions, not InterationA - but that's true regardless of which Input system you use.

    Have you seen the additional instructions on the wiki page? Try without the Optional Mouse Input Module, but instead the Input System UI Input Module that is Unity's replacement for the default Standalone Input Module. The wiki mentions creating a new Actions input asset, but it should work with the default one in the New Input syste package. I just tested this myself and had no issue navigating the default Pause menu directly.

  • It turned out I got it working with a weird combination. I used the default Unity Input System UI Input Module as you suggested. But I also need the Optional Mouse Input Module attached but inactive. I have no idea why it has to be there, but I can stick with that at the moment.

  • Hey, I've tried out the integration script. I've been having some trouble getting the FreeAim for the First person to work. I just can't ever seem to get CursorVertical or CursorHorizontalto hit. All of the other bindings work except mouselook.

    InputSystemIntegration.cs

            private float Custom_GetAxis(string axisName) {
    
                Debug.Log($"Custom_GetAxis <b>{ axisName} </b>");
                //Debug.Log($"move:  { movementAction.ReadValue<Vector2>()}");
                //Debug.Log($"cursor:  { cursorMovementAction.ReadValue<Vector2>()}");
    
                switch (axisName) {
                    case "Horizontal":
                        return movementAction.ReadValue<Vector2>().x;
    
                    case "Vertical":
                        return movementAction.ReadValue<Vector2>().y;
    
                    case "Run":
                        return holdToRunAction.ReadValue<float>();
    
                    case "CursorHorizontal":
                        Debug.Log($"Cursor X: {cursorMovementAction.ReadValue<Vector2>().x}");
                        return cursorMovementAction.ReadValue<Vector2>().x;
    
                    case "CursorVertical":
                        Debug.Log($"Cursor Y: {cursorMovementAction.ReadValue<Vector2>().y}");
                        return cursorMovementAction.ReadValue<Vector2>().y;
                }
    
    
    
                return 0f;
            }
    
    
  • What do your Debug.Log statements reveal? Is CursorHorizontal being requested but the returned is zero, or is it not being requested at all?

    If it's the former, it may be an issue with the way your "Cursor Movement" InputAction is configured.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.