'How do I get a button that is held down to change what it is doing after a power up ends?

In the game I am trying to make. When I am holding my fire button and I pick up a power up SuperShot, it continues to fire my regular laser unless I release my fire button and press it again. The same thing happens again when the power up ends. I have researched and I cant seem to figure out a way to check on where the power up is active while holding the key down.

    private void Fire()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            if (SuperShotIsActive)
            {
                superShotFiringCoroutine = StartCoroutine(SuperShotFireContinuously());

            }
            else if (!SuperShotIsActive)
            {
                firingCoroutine = StartCoroutine(FireContinuously());
            }
        }
        if (Input.GetButtonUp("Fire1"))
        {
            StopCoroutine(firingCoroutine);
            StopCoroutine(superShotFiringCoroutine);
        }

    }


Solution 1:[1]

You might be able to fix this by looking away from the button itself and into the code of the actual firing of the weapon.

//psuedocode-ish example. Just for the concept
//not necessarily the best idea to use a for loop but maybe it works for you.

FireContinuously()
{
    for(int foo = 0; foo < ammo; foo++)
    {
        if(!SuperShotIsActive)
        {
            //normal firing code you have goes here
        }
        else
        {
            //supershot code goes here
        }
    }
}

In FireContinuously() (which I assume is a loop of some sort) you can add a check before each shot to see if the player now has the powerup and the necessary logic to change to the appropriate SuperShotFireContinuously(). Do the opposite for SuperShotFireContinuously() to change to FireContinuously().

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1