# Increase Jump Through Mouse Clicks?

A quick beginner question(I know shameful). How can I increase the jump force of my Player depending on how many mouse clicks i do? For an example If I click the mouse 1 time, it would increase my Jump force by 10. If i click it 3 times it would increase it by 30 since 10 x 3 = 30. If I click it 100 times it would increase it by 1000, and so on. So how can this be done? I know a simple mouse click if statement, but not by how many times the mouse is clicked. That’s the hard part. Here’s my Player script, very simple:

``````public class TestCharacterController : MonoBehaviour {

public float maxSpeed = 10f;
bool facingRight = true;

public float jumpForce = 1f;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void FixedUpdate () {

float move = Input.GetAxis ("Horizontal");
rigidbody2D.velocity = new Vector2 (move * maxSpeed, rigidbody2D.velocity.y);

if (move > 0 && !facingRight)
Flip ();
else if (move < 0 && facingRight)
Flip ();
}

void Update(){

if(Input.GetMouseButton(0))
rigidbody2D.AddForce(new Vector2(0, jumpForce));
}

void Flip()
{
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}
``````

I NEED it to keep track of how many times the mouse button is click. Then it could add it up and apply it when I want it to(things just got complicated, which is fun!). So to sum it up, clicks mouse button how every many times, keep track of how many mouse clicks and adds the proper jump force, it stores it away until I want to apply it at any time(whether by coroutines or something else). Simple? Maybe but a little too complex for me. Please help if you can.

Simply take a variable say

``````int clickCount;  // Can be static if you want

if(Input.GetMouseButton(0)){
clickCount++;

//can put conditions based number of clicks . eg
if(clickCount==5)
// Add this much force and after this you want to reset the clicks just set clickCount==0

rigidbody2D.AddForce(new Vector2(0, jumpForce));
}
``````

I hope this is what you want.