Search Unity

How far I walk on my procedurally generated world before things go haywire

Discussion in 'Scripting' started by nikizor, Dec 3, 2012.

  1. nikizor

    nikizor

    Joined:
    Dec 3, 2012
    Posts:
    2
    Howdy Unity Folks,

    I have created a few scripts that essentially generates perlin noise and applys the heightmap to a mesh and with a combination of chunking I've gotten a nifty procedurally generated world going, I can walk extremely far in one direction but my question is will there be a point in time (Not really a question of will it happen but when it happens) that the game will bug out and things will stop functioning correctly? If anyone could tell me what I should be limiting the map size to it would be really appreciated.

    -Johnny Guitar
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Floating point has 7 digits of precision, more or less, so ideally you should try to keep everything within 10K units of the origin.

    --Eric
     
  3. dilbertian

    dilbertian

    Joined:
    Aug 13, 2010
    Posts:
    74
  4. Drezta

    Drezta

    Joined:
    Nov 4, 2012
    Posts:
    8
  5. nikizor

    nikizor

    Joined:
    Dec 3, 2012
    Posts:
    2
    My only question is that how would this work/interact with other players since the game is multiplayer? Would we have to create some sort of Quadrant where certain chunks are indexed?

    I'm confused on how this would work with multiple clients and having persistency work with it. I was thinking for the saving of item locations there could be an indication of the quadrant its in and then coordinates specific to the quadrant.

    if anyone could help me out with what would work and what needs to actually be scripted (not asking for it to be done just need to know what I need to script)
     
  6. dilbertian

    dilbertian

    Joined:
    Aug 13, 2010
    Posts:
    74
    I would recommend seperating your logic/player tracking layer from your presentation layer. Only present the information to the client within the ~10k range and anything outside of that range you track but don't necessarily have to present within the GUI.

    I think FHolm had created a server system a while back that implements a very similar capability which you may want to have a look at. Here is the link: http://forum.unity3d.com/threads/111299-Release-SlimNet-Public-Alpha-(Free)

    I have run some tests in my multiplayer game with a floating origin and have set up a global position object to track the current offset - as in my case I may Instantiate new players as they enter the game or Destroy and/or Deactivate players who become outside of your ~10k range.

    Without knowing more about your system architecture, it's hard to give advice on which is the best approach. If you will be giving your game away for free and it will only be allowing a small number of players (2-8), a pier-to-pier master/client approach may be fine, but if you plan on making this a pay product, an authoritative server should be a reqiurement.

    For our project, we are using a multi-server approach where 1-n servers load balance the player login, credential verification/validation while there is another server per "Quadrant". We have a back end channel where servers can talk server to server as well, so they can all stay in synch and we can use session/security tokens to improve performance for the verification/validation when jumping from server to server.

    -Tim


     
    Last edited: Dec 4, 2012