Forum rules - please read before posting.

“New” input system integration - additional Action maps

edited March 13 in Technical Q&A
Hello everyone,
I’m trying to extend the features of Ac and implement system that requires additional Action maps and switching to them accordingly. Integration from downloads page includes two action maps which are both activated by default. So I created a third one. However, no matter what I try, it is not allowing me to switch to the third. As if game was completely refusing its existence.. even if I tried extending the ControlsReader with playerinput.SwitchCurrentActionMap it just won’t switch to it.

Did anyone attempted such thing already?

Comments

  • Are the inputs in your new Action Map being read by a separate asset/script, or are they AC inputs?

    The ControlsReader doesn't reference specific Maps - if I move e.g. the InteractionA Action to a new Map, it's still read in testing.

    Can you share more details / steps to recreate your issue?

  • Thank you for quick answer Chris,

    as it tends to usually happen, I seem to have found solution right after asking.

    I attach script to the ControlsReader prefab

    using UnityEngine;
    using UnityEngine.InputSystem;
    public class test : MonoBehaviour
    {
        private UnityEngine.InputSystem.PlayerInput playerInput;
    
        void OnEnable(){
            if (playerInput == null){
                playerInput = GetComponent<UnityEngine.InputSystem.PlayerInput> ();
                if (playerInput == null){
                    Debug.Log("AC's Controls Reader component requires Unity's Player Input component to be assigned", this);
                }
            }
            playerInput.actions.FindActionMap("Player").Disable();
            playerInput.actions.FindActionMap("UI").Disable();
            playerInput.actions.FindActionMap("Combat").Enable();
            playerInput.actions["Press"].performed += LogPress;
        }
    
        void OnDisable(){
            playerInput.actions.FindActionMap("Combat").Disable();
            playerInput.actions.FindActionMap("Player").Enable();
            playerInput.actions.FindActionMap("UI").Enable();
            playerInput.actions["Press"].performed -= LogPress;
        }
    
        void LogPress(InputAction.CallbackContext context){
            Debug.Log("I just pressed Press in Combat Action Map");
        }
    }
    

    Once I enable this script, it turns off the AC action maps and enables my Custom one, and opposite happens on disabling of this script. I don't know why this didn't seem to work before, but it seems to work perfectly now. Maybe it was messing up initialisation of Input System itself before as I'm enabling this script only when I need the switch and not right away.

    To answer the question, New ActionMap will not contain any AC inputs, it will run separately (probably firing inputs from this "test" script)

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.