Search Unity

Question Why do multi-button functions not always work?

Discussion in 'Input System' started by Th0masThe0bvious, Mar 24, 2023.

  1. Th0masThe0bvious

    Th0masThe0bvious

    Joined:
    Aug 22, 2018
    Posts:
    80
    I'm making a game that has a few moves executed by pressing multiple buttons at a time. I'd say it works, 90% of the time. But this needs to be done commonly enough that the other 10% will definitely show up in a play session, and worse, doing this move is required to break out of jams that are otherwise fatal. Oh and yes, this is in Update rather than FixedUpdate. The relevant code follows:

    Code (CSharp):
    1. if (Input.GetButtonDown("Block"))
    2.         {
    3.             canSpin = true;
    4.         }
    5.         if (Input.GetButtonUp("Block"))
    6.         {
    7.             canSpin = false;
    8.         }
    9.  
    10. verticalInput = Input.GetAxis("Vertical");
    11.  
    12. if (canAttack && canSpin && (Input.GetButton("Run")) && (verticalInput < 0) && (currentSP >= 10))
    13.             {
    14.                 canAttack = false;
    15.                 stunTime = 0;
    16.                 //playerAnimator.SetBool("Stunned", false);
    17.                 currentSP -= 10;
    18.                 HUD.spSlider.value = currentSP / maxSP;
    19.                 UpdateStatText();
    20.                 //Debug.Log("Hotblooded attack!");
    21.                 fireSpinCollider.GetComponent<HotbloodedAttack>().damageAmount = punchPower + kickPower + defense;
    22.                 //fireSpinCollider.GetComponent<MeshRenderer>().enabled = true;
    23.                 fireSpinCollider.GetComponent<CapsuleCollider>().enabled = true;
    24.                 currentBehavior = playerBehavior.FIRESPINNING;
    25.             }