Search Unity

  1. Unity 2020.1 has been released.
    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

New input system If statements

Discussion in 'Input System' started by ewanchurchill, Mar 30, 2020.

  1. ewanchurchill

    ewanchurchill

    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,381
    Code (CSharp):
    1. if (controls.player.fire.triggered)
    2.     Fire();
    3.  
    4. var look = controls.player.look.ReadValue();
     
    karl_jones likes this.
  3. ewanchurchill

    ewanchurchill

    Joined:
    Oct 10, 2018
    Posts:
    20

    Thank you!
     
  4. Fenrisul

    Fenrisul

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