Creating the Orbital Mechanics Simulation
When thinking about the various components involved in SpaceTruckerPlanningScreen
, it’s important to consider how the simulation runs. Every frame (actually, it could be potentially more than once per frame, but for simplicity’s sake, we’ll go with once per frame), the physics simulation updates its own internal state. That state is largely opaque to us – though if needed we can always access it – but is manifested through the post-physics step changes that are made to an object’s position and/or rotation. To make our CargoUnit
perform the necessary gravitational boogie, we need to tell the physics simulation the force it should impart, calculated from the accumulated gravitational forces of the system.
Though very similar in appearance, the InFlight
game state has two major differences from ReadyToLaunch
: when we are InFlight
, we want the cargo to be affected by the gravity of all the different...