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

No release callback when using D-Pad or WASD for discrete movement

Discussion in 'Input System' started by Daishikofy, Nov 18, 2019.

  1. Daishikofy

    Daishikofy

    Joined:
    Nov 2, 2018
    Posts:
    4
    Hi guys!

    I runned into a little problem with the new input system which is the following:
    I am currently working on a 2D-Zelda like player controller with 4 directions for my character. Usually, when changing direction, the player will, for a moment, press two directions at the same time.

    Let's say, you are going left and want to go up. You will slide your finger from the left arrow to the up arrow and for a moment have both left and up arrow pressed but eventualy end up with only the up arrow pressed.
    The new input system does not quite react to this situation cause for it the D-Pad was never quite released so it will not notify the controller that what is curretly press isn't the left arrow anymore.

    I just wanted to know if anyone had rush into this problem before ( I guess I am not the only one ) and how did you managed to solve it ( if you did ).

    What I am going to try now is separate each direction so I have an horizontal and vertical axis, I imagine it will work but it kinda breaks the idea of the input system haha.
     
  2. Daishikofy

    Daishikofy

    Joined:
    Nov 2, 2018
    Posts:
    4
    Well, the idea of having a Horizontal and a Vertical axis does not seams to work cause one of the action is never even being called.....
    I don't really know what is going on, going to invastigate further. Will update here if I find anything.
     
  3. Daishikofy

    Daishikofy

    Joined:
    Nov 2, 2018
    Posts:
    4
    The reason why my previous solution wasn't working was because I was using D-PadX and D-PadY. I thought those options would isolate the input: If you press up, D-PadY is being pressed but not D-PadX. This is NOT what is actually happening. When you press "Up" the input system will understang that you are using the D-Pad with a value of (0,1) and will pass this value to your first inputAction using the D-Pad.
    In my case it would only call Horizontal or Vertical with a value of 0 when I would respectively press Vertical and Horizontal buttons.

    My solution ended up creating two 1D inputActions (Horizontal and Vertical) and manually setting their positive and vegative values.

    I don't know if this is the way you should do it, I guess their is a better solution but for now it is what I found.