A VERY good day today code-wise. I’ve spent the last couple of evenings working on orbital mechanics and just got the new system working tonight. I basically completely gutted the prototype system and rebuilt it. For the prototype, many things were hard-coded and placeholder and ALL of that is now gone.
The new system allows for circular and elliptical orbits (no orbit is perfectly circular obviously, but still…), clockwise and counter-clockwise rotation, orbital inclination, and multiple gravity wells acting on a single object. Again, there’s going to be a limit on how many bodies can act on another at any one time, but I’ll have a 2-body system at least so that Lagrange Points will be simulated…
What’s cool is the entire system is dynamically updated–no look-up tables, no cheats. For example, in my test simulation I was running I had a sun, planet and a moon. All I had to do when the simulation started was give the planet and moon both a “nudge” with the proper Tangential Velocity and they just started orbiting. Adjusting the initial velocity caused the expected orbital variations. And, the entire system can be time accelerated (which it has to for time elapse while in Suspended ANimation on longer journeys).
Of course, sling-shots past planets/moons, and entering an orbit around them, are now very achievable. It was possible with the prototype system, but with the pre-calc’ed hard-coded values it was tricky and didn’t always work as expected. This new system allows for properly calculated orbital entry trajectories, orbit transitions, escape velocities, etc.
Now, obviously not EVERYTHING is in yet. Definitely though, what’s needed for the immediate future is in and running very well :)
I’m really quite excited about this. In fact, I thought of some new gameplay elements based on the freedom of this system while I was working on it (I had a few “wouldn’t it be cool IF…” moments), including a new way to “earn a living” once the Maverick Module is added later…
And that’s about it for tonight. I’d like to keep working but I guess I should get a few hours sleep… :)