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

Input History or Input Buffer

Discussion in 'Input System' started by templewulf, Oct 31, 2019.

  1. templewulf

    templewulf

    Joined:
    Dec 29, 2013
    Posts:
    52
    Hi all,

    In order to discern player intent, my game records axes from UnityEngine.Input into a list, then checks the inputs of the next few updates to see if the player entered more commands. For example, if they imperfectly press two buttons together, or if they input a direction right after a button. This also extends to fighting game-style special move inputs.

    Is there anything like an input history built into the new input system? Or some kind of grace period adjustment for modifiers? Or should I just create a public function for each conceptual button (instead of actions) and apply modifiers myself?

    Thanks!
     
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    As far as stuff goes that currently comes built in, there's InputEventTrace to record input at the event level and InputActionTrace to record input at the action level.
     
    akast07 likes this.
  3. templewulf

    templewulf

    Joined:
    Dec 29, 2013
    Posts:
    52
    Thanks! I poked around, and I think I can make that work.

    Is there any combination of Interactions that I can use to create a double-tap to dash input? I.e., 1) a player doubletaps right (either the D key, the arrow key, or the dpad on a gamepad), 2) their character begins a dash animation 3) their character continues running right while the key is held, and 4) their character stops running when the key is released.

    I can make this happen using the action trace and C#, but I feel like I might be duplicating your work that way.
     
  4. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Not out-of-the-box ATM. There's MultiTapInteraction but ATM that's a trigger-once kinda deal. I.e. it will perform when reaching the tap count and then go back to waiting. I'm thinking that interaction would probably be more useful if it actually stayed performed after the tap count has been reached until the button is released next.
     
  5. templewulf

    templewulf

    Joined:
    Dec 29, 2013
    Posts:
    52
    Thanks for letting me know! I can try my hand at a custom interaction.

    There are certainly cases where double-tap-immediate-release makes sense, like double-clicking in mouse or touch oriented games. But having another interaction for double-tap-and-hold certainly makes sense for gamepad oriented action games.

    I love the new release so far, awesome work!