Search Unity

New input system If statements

Discussion in 'Input System' started by Ewan-Churchill, Mar 30, 2020.

  1. Ewan-Churchill

    Ewan-Churchill

    Joined:
    Oct 10, 2018
    Posts:
    20
    Hi I want to know if its possible to use the new input system in if statements.

    The screenshots show my old Update() method which used input.keycode but i want to change that to the new system but haven't had any luck.

    Thanks in advance.

    Unity6.JPG
     
  2. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,550
    Code (CSharp):
    1. if (controls.player.fire.triggered)
    2.     Fire();
    3.  
    4. var look = controls.player.look.ReadValue();
     
    karl_jones likes this.
  3. Ewan-Churchill

    Ewan-Churchill

    Joined:
    Oct 10, 2018
    Posts:
    20

    Thank you!
     
  4. Fenrisul

    Fenrisul

    Joined:
    Jan 2, 2010
    Posts:
    576
    Code (csharp):
    1.  
    2. InputSystem.GetDevice<Keyboard>()[Key.E].wasReleasedThisFrame
    3.  
    Is also valid as the in-line parallel to the old system.
     
unityunity