## Formula to fly up to a point at different speeds

Hello,

I'm trying to build a game that has birds fly up on the Y axis (I'm ignoring the X axis for now).

What I'm trying to achieve is for the the birds to fly up against gravity (in this case set to 240) to a predefined height and at different speeds.

E.g. Bird1 flies up 400 pixels at a speed of '10'. Bird2 flies up 400 pixels at a speed of '5'.

The variables I can set is 'velocity' and 'acceleration'. I have a gravity factor of 240 trying to push the birds down at all times.

What formula would I use for this?
 PhysOrg.com science news on PhysOrg.com >> Ants and carnivorous plants conspire for mutualistic feeding>> Forecast for Titan: Wild weather could be ahead>> Researchers stitch defects into the world's thinnest semiconductor

 Quote by harleyon Hello, I'm trying to build a game that has birds fly up on the Y axis (I'm ignoring the X axis for now). What I'm trying to achieve is for the the birds to fly up against gravity (in this case set to 240) to a predefined height and at different speeds. E.g. Bird1 flies up 400 pixels at a speed of '10'. Bird2 flies up 400 pixels at a speed of '5'. The variables I can set is 'velocity' and 'acceleration'. I have a gravity factor of 240 trying to push the birds down at all times. What formula would I use for this?
Hey harleyon and welcome to the forums.

If you were to use a force framework for physics, what you can do is to create a force vector that always down (i.e. towards the earth). So for 3D it would be towards the negative y-axis.

If you are able to have say a scene where you can 'fly around the earth' then the force vector should point towards the centre of your virtual world: if its flat don't worry about this.

Then for specifics you need to do unit conversion and find the right parameters. The reason is that in games, we don't use 9.8m/s even if the units with respect to the perspective and size of the characters and other objects is right.

So you will need to figure out a ratio for screen units with respect to metres and then specify a coeffecient for your gravity. The force vector then given that positive y points 'up' will be (0,-g * scaling) where the g is your coeffecient for gravitational force and scaling is your scaling calculation to convert metres into game units.

What you do after this is that the bird supplies a force to overcome the gravity and that force will usually depend on the direction of flight from the user. You can (and this is why its better to have this system), add as many forces as you want for things like aerodynamics if you want to add this later.

Once you have this force system, you end up taking all the forces on the object and then you add them together to get the net-force. You then integrate this force into the object itself and it will move in that direction.

You will also need to supply a mass for the bird. Then what happens is you take all of this and you get the momentum over time for the bird and the velocity component is what you use to move the bird.

The momentum is calculated as the integral of the force. Basically what you do is you have a small time value and the momentum increases by F * dt = mv (v is velocity which is a vector). Then given that you know the mass, you then take the velocity and increase the displacement of your object by v * dt (i.e. add this to your velocity) to get your position of your bird and keep doing that each frame of your game.
 ... in the meantime the additional acceleration is given by -(u2+2.g.s)/2s) where u is initial speed, g is background 'gravity' and s is the height. I think your bird is going to be flapping for a long time, though.

## Formula to fly up to a point at different speeds

Great - thanks guys. I'll give it a go.