Search Unity

Reading Last Key For Top Down Controller

Discussion in 'Input System' started by Jonathan-Westfall-8Bits, Oct 13, 2020.

  1. Jonathan-Westfall-8Bits

    Jonathan-Westfall-8Bits

    Joined:
    Sep 17, 2013
    Posts:
    271
    Hello, I was wondering if anyone knew the best way to grab the last key that was pressed or check to see if there is a change in state for certain actions.

    I am currently writing a top down character controller for 2D. I need to see what the last button that is clicked so I can set the direction that the player will be facing.

    Problem is at the moment let's say I am holding the up button and the right button a config for a dpad movement inside the input actions editor. Since I am holding both of them and getting values from both I don't know which was the last one I pressed sense both of them are sending data that they are both being held. So I could hit right and than up and it will show the right animation even though up was the last one hit.

    Is there any simple way to just see what was the last button pushed in an action is?