# How to change the gravity with a click

How to change the gravity of a ball upward with a click Then change it again downward with another click And so on In unity

void ReverseGravity()
{
Physics2D.gravity = new Vector3(0, -1.0F, 0);
}

void ApplyGravity()
{
Physics2D.gravity = new Vector3(0, 1.0F, 0);
}
//if you are not using 2D then use Physics.gravity = new Vector3(0, 1.0F, 0);
//you could also  use Rigidbody AddForce to get your desired effect without changing any physics.
//you can set up a bool normalGravity and use something like this in a LateUpdate()
if(Input.GetKeyDown(KeyCode.Mouse0))
{
if (normalGravity)
{
normalGravity = false;
ReverseGravity();
}
else
{
normalGravity = true;
ApplyGravity();
}
}

Physics.gravity *= -1.0f; // :P