Airplane pitch, roll with setLocalForce()

makr

24-04-2008 20:24:39

Hello all!

I'm currently trying to implement some dumbed-down physics for an airplane game that I am working on. Currently this is what I'm doing in my physics call back:

- Adding global force of gravity on the global Y-axis.
- Adding local force of thrust Vec(0.0, 0.0, X.X) on plane's orientation at the plane's local origin.
- Adding local force of roll Vec(0.0, X.X, 0.0) on plane's orientation at a offset of (size.x, 0.0, 0.0) relative to the plane's local origin.
- Ading local force of pitch Vec(0.0, X.X, 0.0) on plane's orientation at a offset of (0.0, 0.0, size.z) relative to the plane's local origin.

I have yet to "simulate" drag and lift. Does this approach sound ideal? I have read that you should never setForce or setOmega. I believe that I have read on the Newton Dynamics forums that to "turn" an object, I should be using local forces (as I am).

If this is an decent approach, I have the following problem: my roll and pitch functions apply a force that give it some inertia that takes some time to neutralize. For a plane's pitch and roll, I want to have a direct and immediate effect (more of a setLocalForce), but it seems that this will affect other forces (like my gravity, and thrust, and soon-to-be pseudo-drag/lift).

Could someone steer me along the correct path? Also, would implementing a form of drag and lift solve this problem? It doesn't seem so, but I could be wrong.

Thanks.

Edit: Another question. My body size is roughly ( 100, 20, 100 ). To perform the roll/pitch, the mass had to be set to an insane amount (size * 10000000). Otherwise, the addLocalForce() for the roll/pitch had no visible effect. Where is my fault in this logic?

Game_Ender

24-04-2008 21:03:45

Think of the scales as 1 unit == 1 meter, and 1 mass unit == 1 kg. So look up a real aircraft on wikipedia to get some decent numbers ex:
Mass: 12,000kg
Thrust: 65000 N

That might enable to have a better testing environment. If you don't have lift how does your craft get off the ground? It would be hard to roll a block on the ground.

makr

24-04-2008 21:22:42

Well, I have "lift" in the sense that I can pitch "up" towards the sky, and then apply a thrust to it's local z axis, which would apply a Vec( 0, X.X, X.X) direction in terms of the world.

So, I can get off the ground :) I don't have lift in the following sense:

If my wings are parallel to the ground, and I am applying thrust to +Z, the plane should gain altitude slightly (depending on whatever scale), and defy the gravity force.


So yeah; I can fly, but it's hard to maneuver with the lifespan of the force applied with addLocalForce() for the pitch/roll. For example, if I quickly tap left on the analog stick, it will apply a roll towards the left for a couple of seconds, as opposed to just rolling a specific amount.

Edit: Forgot to say thank you for the metrics used with the mass. Makes total sense; duh :)

makr

25-04-2008 02:48:19

Perhaps it is addImpulse() that I want (and translating local force/position into word-relative values). I'm going to attempt this, and see if this does the trick. If anyone absolutely knows that this is a wrong alley, please post a reply--I'll be monitoring :)

Edit: Upon further investigation, it does not appear that this will achieve the desired results of my original problem (in the first post). Sigh.