Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to understand multiple interactions?

Discussion in 'Input System' started by filod, Nov 25, 2019.

  1. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    223
    let's say i have Hold and Press (release only) same time:
    upload_2019-11-25_15-30-47.png
    if hold was performed, then press won't start/perform after release the button
    upload_2019-11-25_15-31-19.png
    if hold was canceled, then press would start&perform
    upload_2019-11-25_15-30-35.png

    the document says
    "If multiple Interactions are present on a single Binding or Action, then the Input System checks the Interactions in the order they are present on the Binding"

    is this a bug or i misunderstand things?

    meanwhile, another "bug-like" behavior in hold interaction is, action.ReadValue<float>() will return 0, after action.triggered even i still hold button, if i bind this action to a Axis control (gamepad trigger), action.ReadValue<float>() will jump between 0 and actual axis between Update calls, that's really confusing to me.
     

    Attached Files:

    Last edited: Nov 25, 2019
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    It's expected behavior (though, granted, not the most intuitive one; plus docs need improvement).

    Basically, the list represents an order of priority. An interaction higher up in the list preempts an interaction lower down.

    So here, Hold is driving the entire sequence to completion. Press never gets a shot. When Hold is performed, the action considers the input sequence to be complete and resets the entire chain.

    Here, Hold again gets first shot but then basically aborts and says "I can't handle this input sequence". So with that, the system goes to the next interaction and Press gets a shot.

    Yup agree, it's confusing behavior of Hold. The problem has come up multiple times in different forms and I'm about to change Hold to stay in performed state until the button is released (which will implicitly fix the problem you're seeing here).
     
    filod likes this.
  3. Superstition

    Superstition

    Joined:
    May 22, 2015
    Posts:
    12
    Is it just me, or is the above broken now? It seems to, in the example above, only call hold start, hold can, press can, and completely misses the press start