Search Unity

Large world, floating origin, how is it done?

Discussion in 'Connected Games' started by Gibbonuk, Feb 26, 2015.

  1. Gibbonuk


    Dec 10, 2013
    Hi all, I have a large world simulator and ive spent a lot of time smoothing out multiplayer and it seems to work great so far (using unity networking).

    The problem I found recently in general (single player too) was at 4000-5000+ units from origin i was getting jitter caused from floating point precision. So I implemented the floating origin system and that so far works nice.

    The problem is i cant really think of a good way to do this over multiplayer?

    The mutliplayer isnt really server authoritive, it has some authority on some things but this isnt rerally needed, there is no scoring or anything and the target audience wouldnt benfit from cheating or hacking so each player simply sends there transform to all and it all gets smoothed out ETC.

    One way I though was when a player reaches my chosen threshold where it "repositons" the world, it sends an RPC to all to do the same? This will be ok if all players are within close proximity (which is very likely) but if one player is at the other end of the world then it will obviously cause issues?

    Any ideas on how I could do this better?

  2. JamesPro


    Mar 5, 2012
    Using Unity's Networking your only going to get a limited number of players on a Server. It's more designed for Multiplayer FPS lobby style games.

    First of all you need to implement AOI... Area of Interest. You should ONLY be sending position updates to players who are actually with in range of the player.

    Next I would create a Grid based System. Each Terrain Chunk would be on a xy grid... The Center would be x0, y0 then spread out from there in ALL directions.

    Then their Position would be based on the Grid and their location with in their current terrain chunk. Have a method for getting the transform position and setting the transform position based on Location in the Grid (Vector2) and their Vector3 Position with in the terrain chunk.

    Once that is all setup then you can move the position of the Terrain Chunk back to the origin whenever needed.
  3. jpthek9


    Nov 28, 2013
    A similar method of networking would be to have the server simulate and distribute information which would take out the possibility of cheating. Instead of having players send positions, send input to the server (i.e. 'Forward key pressed' or 'Forward key unpressed'). The server moves your character based on that input then sends the results to everyone. As James said, you can take it a step further and create an AOI system if there're a lot of players. For each client, the server checks which pieces of information is necessary to give and at what rate. The clients are basically 'dumb' input and output machines while the server does the actual simulation. If you'd like a recommendation for a networking solution that can handle simulations, check out Forge.