Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved How to get all currently clicked buttons from Action

Discussion in 'Input System' started by MaciejZareba_4experience, May 10, 2023.

  1. MaciejZareba_4experience

    MaciejZareba_4experience

    Joined:
    Mar 11, 2020
    Posts:
    21
    I've got defined actions as on screen below.

    upload_2023-5-10_14-48-35.png

    and i want to highlight pressed buttons on my UI

    upload_2023-5-10_14-51-32.png

    How can i get which keys are currently pressed from Move (W,S,A,D) action ? [
    InputAction.CallbackContext context.control.name is my best find but it can only return one key per frame.]

    Bonus question : Let's say I solved problem with getting all input from Move action per frame . How can i get Phase started and canceled for individual key from Move action ?

    Maybe there is totally different solution for that. Let me know your tips and tricks.
     
  2. MaciejZareba_4experience

    MaciejZareba_4experience

    Joined:
    Mar 11, 2020
    Posts:
    21
    I solved it in simpliest way. When Move returns v2 i check if v2.x > 0 then it's A if x<0 then D if v2.y > 0 -> W v2.y<0 => s