How to use GetButtonUp and GetButtonDown on the new Input System?

แชร์
ฝัง

ความคิดเห็น • 13

  • @evanlegrand874
    @evanlegrand874 ปีที่แล้ว

    great video, been looking for this for a long time!

  • @tylerjones9197
    @tylerjones9197 2 ปีที่แล้ว +3

    Thanks dude, Unity Forums weren't helping on this issue.

    • @twilight3272
      @twilight3272 2 ปีที่แล้ว

      Yeah, I was having a similar issue. This seems like such a simple thing to state, but every time I saw a question like this the people waffled around and never just said .canceled would work.

  • @jamieogle6857
    @jamieogle6857 3 ปีที่แล้ว +2

    Very useful video, cheers mate.

  • @martins.8349
    @martins.8349 2 ปีที่แล้ว

    thank you .. you are a man of culture :D

  • @Magma-uw7yo
    @Magma-uw7yo 2 หลายเดือนก่อน

    How do I use for the Send Message behavior ? I try to replace the GetKeyDown with the new Input System, I watch a lot of tutorials but nobody explain me how to use it on an other script

    • @thecodingcultEN
      @thecodingcultEN  2 หลายเดือนก่อน

      usually using Send Message is not the best since it ends up sending message to a ton of objects. It's better to have a reference to the other script(making it public then drag and drop in the inspector or maybe using GetComponent) and then call the method you want directly

  • @willb8930
    @willb8930 3 ปีที่แล้ว +1

    What about just GetButton? For charge-shots and the like.

    • @thecodingcultEN
      @thecodingcultEN  3 ปีที่แล้ว

      you can have a float charge, then use if(GetButton) and a charge++ in it

  • @espiritualidadedesvendada
    @espiritualidadedesvendada 3 ปีที่แล้ว +3

    O teu sotaque brasileiro

  • @WarpaintStudios
    @WarpaintStudios 9 หลายเดือนก่อน +2

    why do all videos show this method, it is WRONG. if you press and hold the button then performed is kept as true until you let go (canceled) this is not the same as getbuttondown but is instead the same as getbutton which returns true for as long as it is held. the only real difference is that with g t button it stays on true even if you release the button unless you call getbuttonup to cancel it.
    get buttondown DOESN'T hold true as long as it is kept held down. it switches to false after less than a second.
    get button: press = true, release does nothing (it stays true).
    get button down: press = true then switches to false.
    get button up: press does nothing, release sets true.
    started: press = true, release does nothing (stays true) - this is like get button.
    performed: press = true, release = false. - this is NOT the same as get button down as releasing it is what changes it's boolean, it doesn't do it itself.
    cancelled = press does nothing, release triggers true - this is the same as get button up.
    Unity REALLY messed up with this one. the closest you can get is by setting the interaction as press only THEN it works similar to get button down.

  • @Ihasfinger911
    @Ihasfinger911 ปีที่แล้ว

    What would this be? I can't wrap my head around the New Input System!!
    private bool isDashing;
    void Awake()
    {
    controls.Gameplay.Dash.performed += ctx => Dash();
    }
    *****if (Input.GetButtonDown("Dash"))*****
    {
    if (!isDashing)
    {
    StartCoroutine(Dash());
    }
    }
    IEnumerator Dash()
    {
    isDashing = true;
    speed *= dashPower;
    trailRenderer.emitting = true;
    yield return new WaitForSeconds(dashTime);
    speed = baseSpeed;
    isDashing = false;
    trailRenderer.emitting = false;