Search Unity

Is there a way to allow some time to release two keys?

Discussion in 'Input System' started by foxnne, Jun 14, 2019.

  1. foxnne

    foxnne

    Joined:
    Apr 18, 2016
    Posts:
    59
    Hi,

    Hopefully this isn't an idiotic question. It might be outside of the scope of the input system, but since it seems to be geared towards using input to trigger actions:

    Say I have a directional input like WASD and my game uses 8 direction movement. And I want to allow a player to continue facing one of the combination directions (NE, SE, NW, SW)

    I can't very easily ensure that has enough time to occur as typically it's not easy to always release both keys at the exact same update.

    It would be great if I could specify some sort of release buffer for 2D Vector Composites so I could recognize when the player released the two buttons very close to one another and not change the characters direction.

    Is this possible? Or would i manually need to do this?
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,775
    For multiple keys, duration of holding etc., you simply can use timers.
     
    foxnne likes this.
  3. foxnne

    foxnne

    Joined:
    Apr 18, 2016
    Posts:
    59
    Do you mean just manually on my own? I know I can just write a simple counter in update or xo routine but it seems there is so much extra functionality to the new input system I just wanted to make sure i wasn't missing anything.
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,775
    Yes. Bur since I don't use Unity new input system, to be honest, you ma be right.
     
    foxnne likes this.
  5. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    I don't think that there is anything built into the input system which would handle this for you, so you will likely have to build this somehow on top of the input system.
     
    foxnne likes this.