Search Unity

[Solved] New input system, switch action map

Discussion in 'Input System' started by Deleted User, Jul 15, 2019.

  1. Deleted User

    Deleted User

    Guest

    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. Deleted User

    Deleted User

    Guest

  3. Deleted User

    Deleted User

    Guest

    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 by a moderator: Jul 16, 2019
    FIFTYTWO and DemonFangZ like this.
  4. FIFTYTWO

    FIFTYTWO

    Joined:
    Oct 21, 2014
    Posts:
    49
    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:
    13
    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.     }