Still Shooting And Aiming After Releasing Both Mouse Buttons

Hello everyone!

When i release the aim and shoot buttons at the same time, my gun stays aimed down sights and keeps shooting even when both buttons are released. Any suggestions?

Here is the Aim method i created:

// Aim
    private void Aim()
    {
        anchor = GameObject.Find("Anchor");
        aimDownSights = GameObject.Find("States/ADS");
        hipFire = GameObject.Find("States/HipFire");        

        if (Input.GetMouseButton(1)) 
        {
            isAiming = true;
            anchor.transform.position = Vector3.Lerp(anchor.transform.position, 
            aimDownSights.transform.position, Time.deltaTime * loadout[currentIndex].aimSpeed);
        }
        else 
        {
            isAiming = false;
            anchor.transform.position = Vector3.Lerp(anchor.transform.position, 
            hipFire.transform.position, Time.deltaTime * loadout[currentIndex].aimSpeed);
        }
    }

This is called in the Update() method.

Hi TheKushBlunts,

You could try using If (Input.GetMouseButtonUp(1)) instead of else statement.
Beside, you should not use Find() method in Update because it’ll affect your performance greatly.