Wrapping the visible world?

I am not entirely sure how to phrase it to get anything useful on google or here, so apologies if this is a duplicate.

To get around co-ordinate space limitations, how would you mass-move things, maintaining relative positions, from, say, -30,000 to +30,000?

Background, to clarify the question a bit:
Hacking on what amounts to a research game. If you’ve played the old game Flatspace (Or any of the X games and SPAZ, smash those together.), think a multiplayer version of that. Looking at Photon for the network side. (No, I’m not insane enough to try to build an MMO solo, just to make that clear. This is a pretentious indie research type of thing.) Edit: For those of you that haven’t, top down 2D space-type game.

Basically, the effect I’m going for is akin to Evochron Mercenary or EVE , where it’s a very, very large seamless world, at a reasonable scale. (So far, the math seems to work for 1 unit = 10 km). Which works great until you hit the 50,000 in any direction mark, then it gets a bit jittery.

I hit on the idea of dividing space into grids, and just transitioning from -40,000 in grid 0,1 to +40,000 in grid 0,0. But I’m not entirely sure how to do that in Unity, let alone in a multiplayer environment. (To make life a bit easier, and to learn from the mistakes of others, single-player starts a local multiplayer server.) Any suggestions?

Well i’ve never played the games you referenced in your post, so it would be helpful if your could add some basic information:

  • Is it a 3D ego-perspective game?
  • Is it a top-down-perspective game?
  • maybe even 2d?

The easiest way is to devide your world into chunks of reasonable size. For a top-down view game you need only a few chunks around your player. In a 3D world you need some more since you can look further.

Most the case all you need is to move all visible stuff by a certain offset depending on the direction you’re moving. Lets say the limit is ± 2000 units. You wouldn’t map +2000 to -2000. It’s better to map it to 0 so you don’t need to switch forth and back when the player flys along a chunk border.

I would use a special script component to mark and find objects that should be translated. With FindObjectsOfType you get a list of all objects with your script attached.

Now you just need somethin glike that:

//C#
float ChunkSize= 2000;
Vector3 currentChunk = new Vector3(0,0,0);

void MoveWorld(Vector3 rel)
{
    foreach(Transform T in objectsInScene)
        T.position = T.position - rel * ChunkSize;
    currentChunk += rel;
}

Vector3 difference = Vector.zero - player.position;
if (difference.x > ChunkSize)
{
    MoveWorld(Vector3.right);
}
elseif (difference.x < -ChunkSize)
{
    MoveWorld(-Vector3.right);
}
if (difference.z > ChunkSize)
{
    MoveWorld(Vector3.forward);
}
elseif (difference.z < -ChunkSize)
{
    MoveWorld(-Vector3.forward);
}

Of course you have to define the chunk loading / unloading distance so when a chunk moves out of this area it gets unloaded and also check for new ones that has to be loaded / created.

This example will move you to the center on the specific axis. So when you fly across 2000 in x direction you will be transported to 0. The virtual position is of course:

Vector3 virtPos = player.position + currentChunk*ChunkSize;