Search Unity

  1. 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
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

WASD in action callback every frame?

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

  1. The-Oddler

    The-Oddler

    Joined:
    Nov 26, 2010
    Posts:
    115
    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:
    115
    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>();
     
unityunity