Do these look familiar:
Runways are indeed not flat. And KSP’s runways are no different.
In fact one might argue that KSP’s runways are too flat! But that’s not what you the fans (or the planes in KSP) wanted. So I was given the task of looking into the Runways.
Well hey I thought.. Can’t be that bad. They don’t look like this do they? Or maybe they do…
Let's Begin!
First impressions were this should be a simple job. Just align the models in Unity. Why hasn’t anyone done this? Well, I can tell you, it’s not that easy at all. The issue begins when you look at the size of the runway models and small inconsistencies that seem to creep in when you import the models into the Unity engine.
Unity has some tools that support object positioning. But the best tool for the job is the vertex snapping tool and this works best when your mesh (the actual triangles that make up the model) has a physics collider attached to it and these have straight, square edges. This is where the fun begins because the Runways in KSP are made up of separate sections which do not have square edges or lend themselves very well to having physics colliders added to them easily because of their shape.The ends and bases of them are rounded and extend into the ground and Unity changed the way physics colliders act from when these models were first created for KSP and the current versions of Unity KSP is running under now.
Level 3 Runway
Recreating the models was just not an option given the time that would take. So the process I came up with was to take the existing model, create cut down duplicates of the model meshes that were square so they could be used as colliders (but also had edges that matched the existing seams), line it all up in the modelling software and export.
Next we import to Unity. Using the new meshes I began adding unity physics colliders and then vertex snapping the sections together. Once this was done the Unity objects were put together into a new Runway prefab (a term in unity which creates a prefabricated object which can then be instantiated when the game is running).
Finally all the references to the new prefab must be re-generated to hook up all the code that supports destructible and upgradable facilities.
What could go wrong? Well there are a lot of these references scattered throughout the game setup. You can easily miss one or two and then wonder, “Where'd my shiny runway I spent so many hours recreating go?”
Once the runway was in the right position there were still some small gaps, and while not letting my OCD get in the way too much, I began painstakingly doing fine tuning adjustments to the positioning of the runway sections.
A bit later and finally everything is right and you get the new and improved runway ready for testing.
Rinse and Repeat
… And so the process then gets repeated with the Level 2 runway.
Luckily I've now got a workflow happening and the Level 2 runway is done in half the time.
With that done… Now what should we do with that lumpy bumpy Level 1 runway?
But that's a story for another day.
Edited by JPLRepo
Recommended Comments