Search Unity

Question Action Map is still working even when disabled

Discussion in 'Input System' started by O4thbreaker, Feb 18, 2024.

  1. O4thbreaker

    O4thbreaker

    Joined:
    Oct 15, 2023
    Posts:
    6
    I have two controllers (player and arrow), that are using action maps and an input manager script. i switch between controllers by pressing a button using EnableActionMap() method.

    Code (CSharp):
    1.  public static void EnableActionMap(InputActionMap actionMap)
    2. {
    3.      if (actionMap.enabled) return;
    4.    
    5.      playerInput.Disable();
    6.      actionMap.Enable();
    7. }
    It worked completely fine until i've decided to trigger a transition through animation. I've made another script with TriggerTransition() method (which is triggered on certain animation frame) and attached it to player controller (because player's model plays the animation).


    Code (CSharp):
    1. [SerializeField] Transform arrow;
    2.  
    3. public void TriggerArrow()
    4. {
    5.     arrow.gameObject.SetActive(true);
    6.     arrow.transform.parent = null;
    7.     InputManager.EnableActionMap(InputManager.playerInput.Arrow);
    8.     CameraSwitcher.Instance.SwitchCameraPriority();
    9. }

    And there it stopped working properly, two controllers are active at the same time, even though log shows that player controller is disabled ( Debug.Log(playerInput.Player.enabled); ). Any suggestions why?
     
  2. O4thbreaker

    O4thbreaker

    Joined:
    Oct 15, 2023
    Posts:
    6
    Alright, after 4 days of suffering I've finally struggled through this nightmare and found a solution. So I guess answer is closed!

    Anyways, feel free to ask how i fixed it (if it will help u)