Formula to fly up to a point at different speeds

  • Thread starter Thread starter harleyon
  • Start date Start date
  • Tags Tags
    Formula Point
AI Thread Summary
To create a game where birds fly upward against a gravity force of 240, a physics-based approach is recommended. Establish a force vector pointing downwards to simulate gravity, and convert real-world measurements into game units for accurate scaling. The bird's upward movement requires a force that exceeds gravity, which can be calculated using the formula for momentum and integrating forces over time. Additionally, the acceleration can be determined with the formula -(u² + 2gs)/2s, where u is the initial speed, g is gravity, and s is the height. Implementing this system will allow for realistic bird movement in the game.
harleyon
Messages
2
Reaction score
0
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?
 
Technology news on Phys.org
harleyon said:
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 :smile:

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.
 
Great - thanks guys. I'll give it a go.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top