# how do i make a balloon physics to go upwards and go down when when i click on it

hi, so im a beginner developer and i would like to know how can i make a balloon move upwards from the start to the end, but when you click it on the ballon he moves a little bit down, like the flap bird physics but instead of going down he goes upwards because its a balloon…

I would try:

bool _mouseOver;

void Update() {
if(Input.GetMouseButtonDown(0) && _mouseOver)
GetComponent<Rigidbody>().gravityMultiplier *= -1;
}

void OnMouseOver() {
_mouseOver = true;
}

void OnMouseExit() {
_mouseOver = false;
}

If you want to do a sort of inverted flappy bird, then you can either use a Rigidbody, invert the gravity constant and use Rigidbody.AddForce whenever you click, or you can create your own simplified version of physics.

The first approach:

Rigidbody rb;
float forceMultiplier = 10;

void Start()
{
rb = GetComponent<Rigidbody>();
Physics.gravity = new Vector3(0, 9.81f, 0);
}

void Update()
{
}

In this case, you need to change forceMultiplier so it matches the mass of your rigidbody. The second approach:

float currentDirection = 1;
float accelerationMultiplier = 0.025f;

void Update()
{
currentDirection = Mathf.Clamp(currentDirection + Time.deltaTime * accelerationMultiplier, -1, 1);

if(Input.GetMouseButtonDown(0)) currentDirection = -1;
transform.Translate(Vector3.up * currentDirection);
}

This code will give you instantaneous direction change. If you want to give currentDirection some time to reach -1, you will need to change it a bit. Also you may need to change accelerationMultiplier. Reinventing the wheel is not considered a good practice, but you can learn a lot of things.

thank you all it helps alot xD