Search Unity

  1. Click here to receive a gift with your purchase of Unity Pro or Unity Enterprise.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Constantly reading action input

Discussion in 'Input System' started by ElnuDev, May 4, 2019.

  1. ElnuDev

    ElnuDev

    Joined:
    Sep 24, 2017
    Posts:
    298
    Hello! I've been starting to tinker with the new input system, and I really like it so far. However, I'm a bit confused on how the input is received
    controls.Harvester.Harvest.performed += context => Harvest(context.ReadValue<float>());
    only triggers when a button is pressed, but how do I constantly read the value? My script only finds out when the button is pressed or held, but never released (such as
    Input.GetButtonUp
    in the old input system.) Any ideas on how to achieve this? Thanks in advance!
     
  2. Elhimp

    Elhimp

    Joined:
    Jan 6, 2013
    Posts:
    21
    There multiple ways. Shortest one is set up your action as "continuous", so it gonna invoke prefrormed event each update. Yet, for me tieing up your buisness logic with input looks like pretty bad idea.
    So, it probably whould be better to use your own Update/Coroutine/RxObservable with "pass through" action, which performed both on button down and up.
     
unityunity