Improbable Icon

Space: SpatialOS and dealing with huge voids



As some of you know I have been working on a Space-based MMORTS called Elrakis. And part of the challenge of this project is to model the scale in such a way that you can play the game and at the same time have that feeling of grandeur.

Distances in space are stupendously large and trying to simulate that would be relatively pointless since most of it is empty. The distances are however significant when it comes to travel times, where things are, gravity wells, and more of such.

The above makes me want to keep track of the real distances. I have thought of a way that might accomodate this, but I am interested in the opinions of others on how you have or will solve this issue. This discussion may also serve as a basis for others to get inspiration from how to approach their own challenge when it comes to this.

I have formulated my criteria as such:

  • I simulate a dwarf galaxy
  • The Coordinates are relative to the center of this galaxy
  • I want to register the real world location of an entity in SpatialOS their Position component to act as a single source of truth
  • I want to minimize the number of physics workers as much as possible
  • Physics Workers can cover at most a radius of 20.000 units (otherwise floating point precision errors in the physics may happen)
  • A unit should be as small as possible, preferably meters (as this is the default for unity)

My current train of thought (and experiment) is to use the SpatialOS’ coordinates as a single source of truth but to make adapters that will convert the coordinates of SpatialOS into a Worker specific position. This is necessary because the positioning of Game Objects uses float’s (and is thus bound to the 20.000 unit radius) but on the physics worker I also want to create zones where a Unit on the Physics worker can have a different value depending on where you are in space.

So for example, if you are in outer space then every unit you cross might equal one lightyear’s worth in SpatialOS coordinates; precision is not important here. However: if you are in combat with another player then each unit on the worker would match 1 KM in SpatialOS Coordinates because you need to precisely select where your units need to go, what formation and which enemy to attack.

This approach does come with some interesting challenges and possible edge cases; for example: if zones are mobile, then all of a sudden the distance between two outer space locations may be harder to calculate because there is a slow zone in the middle.

I still haven’t fully figured out all the technical challenges, not to mention that it would be awesome to dynamically spawn a slow zone when a ship drops out of hyperspace in the middle of outerspace or in a planetary system. The risk would be that these zones may overlap if the algorithm is not defined properly.

But this is just one solution; I was wondering: what problems do others see with such a solution? How would you solve problems with this scale?

I am looking forward to your input; especially the problems that you might see with this type of solution!

p.s. as it stands each SpatialOS unit seems to match 1KM, otherwise the double precision is not enough to represent a position in a galaxy with a 200 LY radius.


Learn Magic!

I’m serious, magicians can make you believe almost anything. As game makers I think we need to be magicians. You could write an incredibly complex system to represent a volume of space at the scale of a galaxy but in the end THE PLAYER DON’T CARE.

The good news is that magic works because humans are easily fouled. Travel time can be an illusion, empty space can be removed, etc… WHILE keeping the “feeling of grandeur”.

Your problem is not technical it’s philosophical!

More info on the gameplay would help me understand what your trying to do.

On the technical side, I did some tests and 40k square km is a good size for a unity worker if your spaceships are 10 to 500 meters long. At 100km the precision is at the cm scale which is good enough.