Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Mouse State does not persist across map changes

Discussion in 'Input System' started by GorillaOne, Oct 29, 2019.

  1. GorillaOne

    GorillaOne

    Joined:
    Jul 2, 2013
    Posts:
    8
    Setup:
    You have two Action Maps, UP and DOWN.
    You have one action in each map. UP has MouseUp and DOWN has MouseDown. Both of these actions have an ActionType of button.
    MouseUp is bound to the mouses left button with a Press interaction Release only.
    MouseDown is bound to the mouses left button with a Press interaction Press only.

    Issue:
    So my desired and expected use of the action maps is to be able to change the map used based on the context the player is in. When the players inventory is open, they will have a different action map than when they don't. This may not be what you're expected use case is, but it was mine.

    The desired behavior is to have the MouseDown event trigger a change from the DOWN action map to the UP action map. Then when the mouse is released it will trigger the MouseUp event. However, it does not. It appears that the mouse action is discarded, and so MouseUp is not triggered until a subsequent mouse click.

    Without this ability, input response events will need to check a separate game state event to determine how to respond to inputs. Using different action maps, we can use the ActionMap as a finite state machine and only fire and listen to events when it would be appropriate to respond to them.
     
    jasonatkaruna likes this.
  2. jasonatkaruna

    jasonatkaruna

    Joined:
    Feb 26, 2019
    Posts:
    64
    I was also planning to use different action maps based on the user context. In my case, it's a separate map for the UI and gameplay in an XR game.