我正在尝试用飞机作为玩家来构建一个简单的侧面滚动器.因此,我想用简单但具有逼真的感觉的物理学来构建简单的飞行控制.我正在使用cocos2D和Box2D.我有一个基本的系统正在工作,但无法使物理感觉正确.
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.
我正在根据用户的输入向平面施加力(这是一个 b2CircleShape ).因此,基本上,如果用户向上推,则会调用 body _-> ApplyForce(b2Vec2(10,30),body _-> GetPosition()).同样,对于-30,则使用
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 flies 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?
推荐答案我最终简化了在飞行中施加的基本力:即推力,阻力,升力和重力.
I ended up simplifying the basic forces that apply in flight: Namely thrust, drag, lift and gravity.
我做了以下简化:
现在,用户只需控制飞机的角度,然后调整推力和升力,并更新世界模拟.
Now, the user only controls the angle of the plane, then the thrust and lift forces are adjusted and the world simulation is updated.
模拟效果不错,但大大简化了.
This gave a good feeling simulation but greatly simplified.
更多推荐
使用Box2D进行简单的2D飞行物理
发布评论