Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

[Solved] New input system, switch action map

Discussion in 'Input System' started by m21-cerutti, Jul 15, 2019.

  1. m21-cerutti

    m21-cerutti

    Joined:
    Dec 29, 2018
    Posts:
    7
    Hello everyone,
    I'm trying to switch the actionmap in my game to go from "Player" pattern of input to "UI" one , but no matter what i've done my computer freeze and i only can shutdown Unity.

    For example, I have tried this one :

    Code (CSharp):
    1. player_input.SwitchCurrentActionMap(player_input.actions.GetActionMap("Player").id);
    and this one :

    Code (CSharp):
    1. player_input.currentActionMap = player_input.actions.GetActionMap("Player");
    But impossible to change in runtime the actionmap used.

    Im using the PlayerInput component with Unity Events behavior that call on a another script the events assiociated.

    Screen Shot 07-15-19 at 08.59 PM.PNG

    If you have a solution, or at least the process to inform the devellopers, I would be gratefull.
     
  2. m21-cerutti

    m21-cerutti

    Joined:
    Dec 29, 2018
    Posts:
    7
  3. m21-cerutti

    m21-cerutti

    Joined:
    Dec 29, 2018
    Posts:
    7
    Problem solved, the input system called the event multiple times in a frame, that's lead to some impredictable behaviour in the function. I have pass through with a boolean that restrict to only one pass, but it's quite dirty. When I find a better solution, i will write down here.
     
    Last edited: Jul 16, 2019
    FIFTYTWO and DemonFangZ like this.
  4. FIFTYTWO

    FIFTYTWO

    Joined:
    Oct 21, 2014
    Posts:
    47
    Thanks, this helped. I used PressOnly interaction for my action to fix this. Press and release events being sent together freeze the editor.
     
    arekrataj and tigerleapgorge like this.
  5. Renardjojo

    Renardjojo

    Joined:
    May 15, 2019
    Posts:
    8
    Hi ! I has the same issue. To fix it I used condition thank's to the context like that :
    Code (CSharp):
    1.     public void Action(InputAction.CallbackContext context)
    2.     {
    3.         if (context.started)
    4.         {
    5.             Debug.Log("Action");
    6.         }
    7.     }