Search Unity

WASD in action callback every frame?

Discussion in 'Input System' started by The-Oddler, Aug 10, 2019.

  1. The-Oddler

    The-Oddler

    Joined:
    Nov 26, 2010
    Posts:
    133
    How can I get a call for the WASD keys every frame?

    I created a Movement action and added the WASD keys to it:

    upload_2019-8-10_23-8-15.png

    However, when I subscribe to the Movement.performed event it only triggers when pressing or releasing the key, rather than every frame:

    upload_2019-8-10_23-10-19.png

    How can I get this event every frame? Or is the only way to save this vector2 in a variable and then use that in the update method?
     
  2. The-Oddler

    The-Oddler

    Joined:
    Nov 26, 2010
    Posts:
    133
    Ok, I found it, you can call the "ReadValue" method directly on the property like so:

    Code (CSharp):
    1. void Update()
    2.         {
    3.             Vector2 inputDir = _input.Player.Movement.ReadValue<Vector2>();