- Home /
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.
Answer by Tung_of_Hanoi · Feb 06 at 08:35 AM
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.
Hello,
Thank you for the tip on using Find() method in Update, I will learn how to be more efficient ha-ha.
Unfortunately, the Input.GetMouseButtonUp function isn't solving my problem. Would it have anything to do with using find in update? How could i change this?