Search Unity

How to handle a multiplayer game with large distances between the players?

Discussion in 'Scripting' started by Kytuzian, Jan 24, 2015.

  1. Kytuzian

    Kytuzian

    Joined:
    Dec 8, 2013
    Posts:
    19
    I'm making a space game, so naturally I want to have a large area for the player to run around in and such.

    I have made a singleplayer game where I fixed the problem by having many sectors (areas around the player which load as the player gets closer to them), and the player's position would be reset to the center sector. However, in a multiplayer game, the players can be in different positions. Therefore, I cannot simply reset the position of the players, otherwise they would always be running into each other even when they were in different sectors, and the new sectors would load on top of the old ones.

    How do I solve this problem for a multiplayer game?
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Exactly the same. Except you only reset sectors for the local machine.

    Google Kerball Unite. They did a good presentation about how to handle large distances.
     
  3. Kytuzian

    Kytuzian

    Joined:
    Dec 8, 2013
    Posts:
    19
    Sorry, I don't understand. What do you mean by "only reset sectors for the local machine"? Current I'm using Network.Instantiate(), so they are created for all the players at once. If a player goes far enough, a new sector would load. When the new sector is loaded, and it's at (0,0) in the game, the new objects will be placed right on top of the old sector.
     
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    You are going to have to be more creative then just Network.Instantiate for this to work. The basic tools are fine for a FPS, but you are asking to do something unusual.
     
  5. Kytuzian

    Kytuzian

    Joined:
    Dec 8, 2013
    Posts:
    19
    Alright, well I was also thinking about changing the layers and such (culling mask for the camera) so that the players would actually be in the same area, but they wouldn't be able to see or interact with each other. Does that seem like it would be viable?
     
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    That could work. But you really don't want to be running the simulation for data that the player does not need. Unless the player can have meaningful interaction with something on the next sector I would suggest not loading the data.