Search Unity

Feedback Surprised CallbackContext.duration is always 0 for Button action

Discussion in 'Input System' started by bitinn, Jan 13, 2022.

  1. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    Hi,

    Maybe I am missing something here, but I just realized the
    CallbackContext.duration
    value is always 0 for my simple left click button action, because startTime and time are identical.

    That makes these value less useful for my case: I would like to figure out how long a button had been held. There are many other ways (like using Hold interactions), but I thought it is intuitive to extract this info from Input System as it already need to know these values.

    I am getting this value from a PlayerInput with Unity Event, I wonder if I need to use another method?

    Thx
     
  2. dtownmitsch

    dtownmitsch

    Joined:
    Aug 12, 2020
    Posts:
    2
    I stumbled across this thread as I had the same issue. Maybe it's a little bit too late, but could be helpful to someone else. For me the solution was to go to the InputActions-Map and add the "Hold"-interaction as a property of the Action you want to get the duration of.