2d trajectory planning of a spaceship with physics

后端 未结 6 1078
逝去的感伤
逝去的感伤 2020-12-23 18:19

I\'m implementing a 2D game with ships in space.

In order to do it, I\'m using LÖVE, which wraps Box2D with Lua. But I believe that my question can be answered by an

6条回答
  •  余生分开走
    2020-12-23 19:02

    Are you expelling fuel? Your mass will change with time if you are.

    Thrust is a reactive force. It's the rate of change of mass, times the speed of the exhaust relative to the spaceship.

    Do you have external forces? If you do, these need to enter into your impulse calculation.

    Let's assume a magical thrust with no mass being expelled, and no external forces.

    Impulse has units of momentum. It's the integral of a force over time.

    First off, you'll need to figure out exactly what the API calls "thrust" and impulse. If you're feeding it a thrust multiplied by a scalar (number), then applyImpulse has to do something else to your input to be able to use it as an impulse, because the units don't match up.

    Assuming your "thrust" is a force, then you multiply that thrust by the time interval (1/30 second) to get the impulse, and break out the components.

    Don't know if I'm answering your question, but hopefully that helps you to understand the physics a bit.

提交回复
热议问题