- Home /
Question by
Murashogg678 · Jun 11, 2016 at 06:59 PM ·
getmousebutton
Bar fills up only when I am holding down mouse button.
This seems like it should be so simple but I cannot figure it out.
Basically, i am making a game like Adventure Capitalist and I want the bars to fill up when I click them. The problem I am having is that i have to hold the mouse button down. I want it to fill up automatically from just a single click. Also, i can click anywhere on the screen but the bars fill up anyway. I need only the bar that I am clicking to fill up. Help please?
Here is my code:
public void Profit()
{
if (Input.GetMouseButton (0))
{
if (fillAmount < 1)
{
fillAmount += (.1f * Time.deltaTime);
}
else if (fillAmount >= 1)
{
m.money += (cheeseValue + cheeseUp.buttonValue);
fillAmount = 0;
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612082706im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Instantiate only One Object 1 Answer
How to make an object appear only when I click and not when I drag 2 Answers
dragging on a gameObject messes with collisions 1 Answer
Sound Stop playing on button release 2 Answers
Problems with Inputs 1 Answer