Search Unity

Read action value only when interaction has occured

Discussion in 'Input System' started by ryanas, Jul 6, 2020.

  1. ryanas

    ryanas

    Joined:
    Oct 2, 2013
    Posts:
    14
    I'm trying to read values from a mouse to move around but only want to do so when the user is holding down a mouse button.

    I've set my Action Type to Value and Control Type is Vector2 with Interaction being Slow Tap (also tried Hold) but the values are constantly being read.

    Is there no way to only send these values if the interaction is set to true? Started is always true in this instance and tried with Performed but no difference.

    Code (CSharp):
    1. _controls.gameplay.look.started += ctx =>
    2.             {
    3.                 _cinemachineInput.OnLook(_controls.gameplay.look.ReadValue<Vector2>());
    4.             };
     
  2. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,682
    ATM this is down either manually storing the button state (or querying it directly like
    Mouse.current.leftButton.isPressed
    ) or writing a custom composite.

    ButtonWithOneModifier only works with buttons and not with Vector2 controls. The request for this kind of functionality has come up frequently. We're planning to have a universal ControlWithOneModifier composite in 1.1.
     
unityunity