Search Unity

Feature Request for Action Time-To-Live and Priority Queue

Discussion in 'Input System' started by AlexGK, Aug 12, 2019.

  1. AlexGK

    AlexGK

    Joined:
    Jul 31, 2013
    Posts:
    38
    Right now, the Input system fires an event everytime an Action is performed. All good there. However, there are times you want that Action to "linger" after being executed.
    Examples:
    • When you're about to hit the ground in a platformer, and press the jump button. If the Action is only registered while the character is airborne, the Action won't do anything, and the player will feel the controls as clunky.
    • Button-mashing in a fighting game, where the player is hitting buttons like crazy, but the game character is locked in an animation. Attacks are chained in fighting games, and if you do precise button checking, all those buttons presses won't count.
    This would be solved giving Actions a Time-To-Live, and by fetching the oldest Action "alive".

    However, another issue arises:
    • Also in fighting games. The player is button smashing, but then he wants to block an incoming enemy attack. If the oldest Action was returned, the character would continue its attack chain instead of blocking.
    This is solved by giving each Action a Priority, and adding them to a Priority Queue. When requested, the Action with the highest priority would be returned.

    All of this is explained with more details and far more elegantly in this document: http://www.adriansotelo.com/Blog/Combat Design 101/Combat Design 101.pdf
     
    Last edited: Oct 14, 2019
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    I think this kind of functionality probably better lives built on top of the input system rather than inside of it. Retaining state and deferring execution will likely fit better with higher-level state management than with the rather low-level, input-centric state management inside actions. Could also be that InputActionTrace is of help here as it allows to retain action state relatively easily.
     
    foxnne likes this.
  3. foxnne

    foxnne

    Joined:
    Apr 18, 2016
    Posts:
    59

    Apologies if I've missed it but I just went through the WIP documentation and couldn't find anything on InputActionTrace. Is there any examples or anything I can use to get started building a similar system to what is described in this thread? Or any information on how to use InputActionTrace?
     
  4. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    There's some documentation emerging here.
     
  5. foxnne

    foxnne

    Joined:
    Apr 18, 2016
    Posts:
    59
    Thanks a ton!