2
\$\begingroup\$

I'm trying to build a simple side scroller with an airplane being the player. As such, I want to build simple flight controls with simple but realistic-feeling physics. I'm making use of cocos2D and Box2D. I have a basic system working, but just can't get the physics feeling correct.

I am applying force to the plane (which is a b2CircleShape) based on the user's input. So, basically, if the user pushes up, body_->ApplyForce(b2Vec2(10,30), body_->GetPosition()) is called. Similarly, for down -30 is used.

This works and the plane flys along with up/down causing it to dive or climb. But it just doesn't feel right. There is no slowdown on climbs, nor speed up during dives. My simple solution is far to simple.

How can I get a better feel for a plane climbing/diving?

Thanks!

\$\endgroup\$
3
  • \$\begingroup\$ This link iforce2d.net/b2dtut/sticky-projectiles had some interesting ideas on air friction etc. \$\endgroup\$
    – Grimshaw
    Jun 19, 2012 at 0:59
  • \$\begingroup\$ This reminds me of a question about simulating paper fluttering... could be overkill for what you're doing, but fyi box2d.org/forum/viewtopic.php?f=6&t=7718&p=33405 \$\endgroup\$
    – iforce2d
    Jun 19, 2012 at 13:38
  • \$\begingroup\$ You also need to consider the transfer of vertical momentum to horizontal momentum when the plane "swoops". Of course this would not apply if your flying a brick. \$\endgroup\$
    – Derek
    Aug 30, 2014 at 15:48

2 Answers 2

2
\$\begingroup\$

Iterative empirical testing. Add some test sliders to your GUI that control the force applied for the upward and downward directions.

Other than that, consider changing the way force is applied. Add gravity into the mix, when the plane is horizontal its lift offsets gravity. The lift decreases with change in pitch. Your force is always forward, when pointing down it's in addition to gravity, when you're pointing up gravity is subtracted from the force.

Basically, think about how to make it more realistic if you want it to feel more realistic.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ In other words "stop being lazy and do it right, it's not terribly hard". I knew this was going to be the answer, but sometimes being lazy pays off. I'll start playing. :) \$\endgroup\$
    – MarkPowell
    Jun 18, 2012 at 21:46
  • \$\begingroup\$ I suppose that sums it up :) Maybe it's not the answer, but it's an answer. Hopefully you get something more useful. \$\endgroup\$
    – House
    Jun 18, 2012 at 22:45
0
\$\begingroup\$

Tilt the nose when up/down forces are applied, and cause the plane to rise or fall more the farther the nose tilts. So the longer you hold the key, the faster the plane rises or falls. Cap it, though, to avoid nosedives.

This should be a tradeoff with airspeed, with forward airspeed decreasing as the plane's nose moves away from a horizontal position. You may want to apply this only to upwards turns so that going down doesn't increase your airspeed.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .