Docking Sim

Hey Folks! Work continues on the docking UI today, and I've got it doing most of what I need now. The next step is to integrate it into the overall game so it acts on real game objects instead of placeholders.

Right now, when the UI spawns, it defaults to undocked state (top half of image above). The white ring and boxes represent our ship and the docking clamps, the blue ring and boxes are the station we're approaching. Initially, the station ring is some random offset from ours, and some random distance. The object is to get the rings aligned closely enough to engage the clamps, docking the ship to station.

Using WASD to control X and Y, and R/F keys to control depth, the user fires the RCS thrusters to nudge the ship towards alignment. Here, I piggy-backed on the Newtonian physics code I added for ship flight to also control the movement of the rings. If you hold down WASD/RF keys, it accelerates in each direction, and when you release the keys, momentum continues to move the rings until you apply retro thrusts.

Once the docking rings are aligned in X, Y, and Z axes, the clamp indicators in the viewport will glow. Similarly, the "CLAMP ALIGN" indicator will light up. When in this state, clicking "CLAMP ENGAGE" will enable the clamps, locking the airlock rings together. And the "DOCK SYS CLAMP" indicator comes on to let you know you're locked-in.

If you miss the mark, the "CLAMP ENGAGE" has no effect, since the clamps have nothing to act on. If you get too close, you'll hit the station, and bounce off in the Z direction. (There's room here to add collision damage and handling some later time.)

Finally, when docked, pressing the "CLAMP ENGAGE" button will disengage the clamps, and the ship will receive a gentle nudge away from the station, causing it to drift away slowly. RCS thrusters can be used here to clear the area until a safe distance can be reached, at which time the fusion reactor can be fired-up and main thrusters used.

That "get a safe distance" part of the experience might still require a custom UI. This will do for now, but I think "safe distance" is probably going to mean ~50km or more, so this might not be very interesting or useful for gauging that position. (Also, there will be ATC permissions to obtain, and other docking ships to avoid. So probably more UI needed for that.)

The other thing I need to do now, rather than later, is hook this up to actual game data. Right now, it's an empty GUI that has no effect on the game. I'll need to make in-game items spawn this UI, and make this UI's inputs affect game objects. And part of that is also adding a system for sliding UIs left and right, so players can quickly jump between panels in more complex control stations like this. Slide left from here to get to the nav console, right from nav to get here, maybe up from here to get to comms, etc. And this'll likely be via arrow keys, with on-screen navigation buttons for redundancy.

With any luck, we can replicate Wash's signature "flip three switches on overhead panel, then do stuff on lower panel" feel when executing more complex actions in the cockpit :)