"The most realistic sailing simulator ever made"
Become a pioneer !!
Stay informed
Access beta versions

Designing multi-user support

Posted on Feb 21, 2016 by Richard Knol

It should be possible to encounter other boats in Sailaway. Of course. And also to sail together on the same boat. Even though there are no avatars.

The typical name for a game with a big world and many people online is MMO (massive multi-player online game). But there is a little catch here: Many of the users are not online, while their boats sail on. And another slight but significant detail: An MMO has a big flat world of a few square kilometers, Sailaway has an immense world of 510 million square km and is spherical.

Offline sailing

The offline boats are updated by the server every 5 minutes or less. In between those updates their position can be extrapolated from the course over ground and speed over ground.

Online sailing

The online boats can connect to a multi-user server and send/receive updates frequently. In an action game this is done about 10 times per second. But there really is no need for that here. Once every few seconds is more than enough if the program extrapolates the speed and course. When in the future races are organized, We can simply up the frequency for the contestants of the race.

Game rooms

In a typical multi-user game, players are connected to a "room" and then receive only the updates from the players in that room. Translated to Sailaway, that would mean you receive updates from boats within a certain radius, but not from boats that are on the other side of the world. This way the network traffic can be kept at a reasonable level.
I decided to divide the world in segments of 1 by 1 degree. If you sail close to the border of a segment or near a corner, you will be connected to 1, 2 or 4 segments at the same time. There are 64,800 segments in total (360 x 180 degrees).

Collision detection

In a game most objects have so called "colliders" these are invisible boundaries that are used to detect if players bump into a wall or into each other. At sea there are very few collisions and I don't plan on adding floating containers and other rubbish to Sailaway. If I'd use colliders, they would all be doing heavy computations every frame, which is about 60 times per second ("did i hit something, did I hit something", ...), whereas the boats will probably never hit anything at all.
Apart from the detection of shallow water, I will simply keep the minimum distance between boats at 2 meters for online boats and 20 meters for offline boats. Not 100% accurate, but good enough.

Curious? Want to know more? Subscribe and gain access to early releases and stay informed.
Previous article Next article