Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Input system On Released

Discussion in 'Scripting' started by NintendoAsh12, Feb 28, 2023.

  1. NintendoAsh12

    NintendoAsh12

    Joined:
    Feb 15, 2021
    Posts:
    90
    hello, am redoing my input script with the player controller Unity events method but how my duck and jump work is that when you press the button you have an if then a bool and then it has an else if bool false like this:
    Code (CSharp):
    1.  if (kb.sKey.isPressed)
    2.         {
    3.             chouch = true;
    4.            
    5.         }
    6.         else if ((kb.sKey.wasReleasedThisFrame))
    7.             {
    8.             chouch = false;
    9.             }
    how would I do that with the unity events
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,606
  3. NintendoAsh12

    NintendoAsh12

    Joined:
    Feb 15, 2021
    Posts:
    90
    true I could do that and I tried that but no input would register I am sorta a noobie when it comes to input scripts and it seemed like the easy way to do the new input system and it worked unlike everything else and I just want to be done working on it and on something else more fun
     
  4. NintendoAsh12

    NintendoAsh12

    Joined:
    Feb 15, 2021
    Posts:
    90
    and I am using it
     
  5. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,606
    Using what? Unity Events, or Unity's input system package?
     
  6. NintendoAsh12

    NintendoAsh12

    Joined:
    Feb 15, 2021
    Posts:
    90
    the input package and it was not working till I selected unity events in the player controller component
     
  7. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,606
  8. NintendoAsh12

    NintendoAsh12

    Joined:
    Feb 15, 2021
    Posts:
    90
  9. RadRedPanda

    RadRedPanda

    Joined:
    May 9, 2018
    Posts:
    1,645
    You should be getting a CallbackContext object, you can get the phase property of that object which would tell you if it's pressed or released.