Believable and Efficient
This week was about finding the balance between believable physics and a server that can carry hundreds of ships moving, shooting, and running into things. We are building a massively multiplayer space game on an engine designed mainly for games about people standing on the ground. This week we performed a detailed pass to find anywhere we'd missed where the engine's defaults did not suit a space game, and fixed them.
Last week's test with hundreds of ships showed us where the server's time went, and this week we acted on it. We mapped every system in our code, compared it with what the engine already provides, theoretical paradigms in game design, and patterns for programming, to look for anything, any ballast, that we could throw overboard. We switched off the parts of the engine that a spaceship never needs, and set out planning a deep sweeping clean-up bundled into seven stages. We finished Step One this week. The primary work this week was simplifying how collisions are made, communicated and acted on. As expected, we cannot show every ship in perfect sync across tens of machines, up to our target of 100. With that in mind, we decided how to simplify ships at a distance: full physics for the ships near you, and a lighter approximation for those further away. The plan was rebuilt to clean up the core first, and this last week finished ahead of schedule. Alongside that, every key in the game is now properly rebindable, and the race system gained a work-over that will help with testing, and be a better game when it's deployed for players to run. On the art and design side, we have new targets to shoot at and a growing set of station buildings to create our zone one colonies with.

Ships flying into the rock field on the collision test level.
Built for people, not machines
Ignoring the backwards and clickbaity title, it's true: the engine we use was designed primarily for games about people and vehicles moving around a world with ground and gravity to keep them on it. A lot of its defaults assume that.
Last week's test showed which of those defaults were costing the server time for every ship, every frame. Among them were some defaults we had missed, or didn't even know were defaults. One item we ran into was, by default, the engine was holding on to navigation for characters on foot even when we had deliberately turned off the Navigation Mesh and didn't implement any navigation systems. There were cameras the server never shows anyone. There was a floor, default in every level, that destroys anything falling below it. Currently nothing in our game walks, space has no floor, and we have a zone 88 million kilometres wide… so all of these were switched off or removed in every level.
Mapping the code
To make sure we were not missing anything else, we drew a map of the game's code. It shows every system, how the systems talk to each other, and whether they fit together. The map showed that most of the code is sound. As expected, it also turned up what every project gathers on the way from a rough first version to a later, more polished one. Some code was no longer needed, some test tools were embedded too deeply and needed to be kept apart from the game, and some jobs, when we compared them, were done properly, but done in more than one way, and tidiness says that we should be consistent. We are now working through each system, cleaning it up, and holding them all to the same standard. One early fix was to the flight modes. The server now enforces Maneuvering itself, so the throttle is held at zero in that mode, whatever a pilot's machine sends.
We then compared the entire code base up against the engine to see if we missed anything that it already provides. We chose this engine so that we could build on what its makers ship. Where our own code does something the engine already provides, we are moving that work onto the engine. Our own code stays only where the game needs something the engine does not offer. This may sound obvious, but there are a surprising number of cases where the engine doth provide, but provideth quietly… so we spent some time searching the source code from the engine for systems we were not aware of to see exactly what we could leverage to our advantage.
Then came the (yes, another one!) updated schedule. The work was put into a fix order, one system at a time, with the game building, running, and flying between every step. The first step is done. Our original ship mover, which we used to develop the physical way that our ships would fly, was retired weeks ago. Now we've scoured the code to make sure it is gone completely, and no stubs or dead ends are left. Any code used only for development now has a home of its own, which the release build never contains, to prevent any contamination or accidental dependency on "development only" and "test" code.
Collisions
Collisions were the heart of the week. By default, when the engine's physics moves a ship, it checks for overlaps only where the ship is at the end of each step. This can lead to strange issues. Take for example the slalom race through the race gates, the "racing rings". At racing speeds, if a ship moves more than one ship length in a "frame", a ship can be on one side of the gate in frame "1" and then on the other side of the gate the next frame, in frame "2". This means that, as far as the game is concerned, a ship can pass through a thin gate between two checks at the end of the frame and never be seen as touching it. It has "teleported" from one side of the gate to the other, and is never seen—by the game—to have passed through it. This is a known issue with fast moving content in video games, so it's nothing surprising. What needs thought, however, is how to do this efficiently and safely so when we have a game running, and—for example—there is a "fleet action" of some sort with 50 or 100 players, and more than 100 non player ships, and weapons fire, and damage allocation, and scoring, and the deathcycle… Shots, missiles, mines, as well as the race gates, all need a better, more efficient answer than what we had, so we researched one approach for all of them.
We started with the shape a ship collides on. Each ship had been colliding on up to eight pieces cut from its model. This was taken from a recommended pattern that was supposed to allow more accurate collisions. This may have been true. However, our tests showed that these multiple shapes were not that much more accurate than just one simple shape, and they cost many times more in resources and time.
Every ship now collides on one simple shape that wraps the whole hull. A moving ship has to collide with a simple shape like this, because our engine's physics cannot collide two detailed models against each other. Still objects, like rocks, stations, and rings, can collide on their own detailed surfaces, which fit them exactly.

A ship inside its simple collision cage.
The engine can provide a collision cage automatically, but it's not very clean. It's uneven. There are gaps where the cage is too big, or places where the model sticks out of the collision volume. When we rebuild the models, discarding the mass stand-ins, we will also build a custom collision cage of our own.

A ship inside its hand-made collision cage.
Now, the key point here is two detailed models, and this has as much to do with moving the collision volume as it does calculating the collision. With that in mind, we built a new test level and flew our ships into a rock field, a hollow station, a race ring, and a parked fighter. The rock field is a cloud of asteroids. We flew 300 fighters into it at once so the server had to work out hundreds of crashes together. Each test was flown once with a simple shape on the target, and once using its "own triangles" from the model's own detailed surface. The results backed up the plan we wanted. With one simple shape, objects like a race ring became a solid disc when the collision cage not surprisingly filled the hole in the ring. On its own detailed surface, there were no triangles in the void of the ring, and the collision cost in time to process was only a fraction higher than the simplified cage. On some models it was even less. Not surprisingly, a single simple shape does not suit a thin or hollow object. It was very nice to see that the numbers bore out our plan and didn't ruin the performance.
One item that we've had on our list and design is "shields as a bubble". It's a bit old skool Star Trek, and we were going to keep it in the mix and drop it if it was too much of a pain or didn't look any good once we got into playtesting. We are now approaching this from the other direction. The shield no longer has a collision shape of its own. It is now a state and a value on the ship, and every hit, bump, and blast is judged on the hull. The look of the shield bubble, if we choose to keep it, will come in the final polish as a pure visual effect, or return as a collision cage of its own around the ship, since the engine cannot stretch a simple sphere into an egg shape.
Collision testing, from the cockpit.
Contact damage
That run showed us the next problem. Working out contact damage was taking most of the server's time.
We need control over contact damage; how much the damage does, to whom, and whatnot. As this was taking a lot of the server's time, we examined how we were getting notified and how we were applying the outcomes. Long story short, this was one of those situations where, by changing when, where, and how we worked with contact damage, a hit became about seventeen times cheaper than before. The worst frame from our tests fell from nearly half a second to under a twentieth. In the busiest second of the test, it still cost more than our target, so there is more work to do.
How the damage feels mattered just as much. If a car hits a wall, it takes a lot of damage. If it then keeps pushing against the wall, it might keep taking damage, but not very much. When taking raw data from the engine, our original version treated a ship held against a rock as a stream of small crashes, and destroyed it within seconds. Not quite what you'd expect. Possible! But not very nice. Now a ship's toughness takes the edge off every contact. A light contact does little or nothing, while a real impact still does a lot. This was all down to how we chose to filter the raw information coming from the engine.
One last bit of efficiency was avoiding the temptation to write "quick test code" that could quietly eat server time. The engine's profiler, a system that measures where the time goes in processing a game, is much more efficient, and we just need to learn how to use, read, and record it mo' betta'.
The beacon bounce.
Bumping ships.
Near and far
Every ship near the pilot has to look and feel exactly right. A ship dogfighting a long way off only has to look reasonably close to the truth. Even tho' for the players "over there" it's real to them, for the players "over here", that's just part of the cinematic backdrop. That difference is where a lot of work on each player's machine can be saved.
The engine offers two ways to show another player's ship on a pilot's machine. One runs the full physics of that ship, and replays a frame completely before presenting it whenever the server disagrees with the pilot's machine and corrects it. This is exact, but costly. The other version steers the ship smoothly towards where the server says it should be, without replaying that frame locally. This method is much lighter, and from a distance it looks pretty much the same.
We had planned a set of flights to compare the two at different numbers of ships. In the end, we already knew the answer: we will need the lighter way. The real questions are when, at what load, and at what range. So we dropped the test flights from the schedule, and decided to use the lighter way for distant ships. The full physics stays for your own ship and the ships near you. The range between them will be a setting, chosen roughly at first and tuned later.
A clearer plan
All of this changed the order of work, so we rebuilt the plan (again!). It now runs from the outside in; or really from the inside to the outside in. Before we do anything more, the core gets cleaned up, one system at a time. That's what we describe above. Then we shift to the "Outside In" starting with a proper zone; one that is wrapped with the beginnings of proper infrastructure that players can log into and have their ships instantiated properly. These ships, with either their player's input or NPC controllers, are defined properly and modularly (they are mostly already). Lastly comes moving to rented servers, and sending each player only what they need. Only then is combat built on top of that.
The plan is based on the pace of delivery from the first five weeks. Each design is now finished a week before it is built, so the building never waits. We will be installing our version of the engine on at least one more machine, so we can be designing on one machine while the other is running automated tests, or building. The goal of the clean-up is a core rebuilt in the most efficient way we can design, leveraging our access into the source code. Old code is deleted rather than kept as a fallback, and each rebuilt system is double-checked against its design, the map, and established principles.
This week's goal became "Clean-up and reschedule". Every part of it was done before the week ended, so the week finished ahead. Version control also gave us a scare, when its store quietly lost some data that its own checks still called sound. We put the old store away whole, upgraded version control, and started the project again in a fresh repository, checked file by file.
The pilot's controls and the race
Every key in the game now goes through the key-binding screen. That includes every function key, because games use them all. Every control profile holds every action, and a player can bind a key, a two-key chord, or an axis on any device that is plugged in. Each radar channel is now the pilot's own switch.
One thought we are going to explore is a context system for the keyboard. The idea is that a few keys on the left set a context for the keys on the right. For example, one key (like the "Q") sets a context (Cargo, Shop, Communication… whatever the pilot chooses to bind) and then the other keys, or the number pad, could use that to toggle the radar's channels, or send a message, or what ev's. This comes from trying to best use a limited number of control keys, and a complex and high volume of actions. "Q" brings up the long range scanning and then the keys from EDC to the right can be used for that context, "A" brings up wingmate contexts, and then the keys from EDC onward can be used for that… We still want to provide touch screen support so this could be done with a GUI (graphical user interface), but in absence of that, we can use the keyboard.
The slalom, and the return.
New models and concept art
Last week's target concepts came into the game as models this week. There are target buoys in several shapes and paint schemes, the hulks of wrecked dropships, and the small tractor. A kit of station buildings arrived too, as parts for building larger scenes. Every one of them is still only a stand-in massing model. Not unexpectedly, our design pipeline is vastly out-pacing our build pipeline! (We'll keep using the stand-ins for now…)
Each import now ends with a set of preview sheets: pictures of every model in the game, sorted by kind. They make it easy to spot a model that came in at the wrong size.

A preview sheet of the station building kit.
The concept art turned its sights to the first colonies and the zone's ambient traffic. I started by drawing a small docking station; one docking disc and a tall living tower.
The original sketch.
We worked through the design as one idea based on looks we already had established, and then broke out the two designs and made the models separately. These were brought together along with a large asteroid in Blender, where we lit them, adding the asteroid texture later.

Colony Concept 02.

Colony Concept 03.
We then branched out and began looking at container cargo ships. Zone 1, tentatively called "Rorke's Drift", is deliberately lower tech. I wanted that to reflect in the design of the traffic, and this ship.
Week six finished ahead of schedule. The server is now cleaner, leaner, and more efficient. The plan cleans up core issues with a projection for a real working shape for the tech supporting the game.
Next: the rest of the core clean-up. First, contact damage made cheap enough for a crowded fight. Then the test tools taken out of the game, blasts on the engine's own push, and mass changes on the engine's own records.