procedural cloud

:oops: machine translation :oops:

Hello. I want to create a multiplayer game in which the procedural level will be created when you create a room. The level is made up of tiles. I tried to add each tile prefab components Photonview and use the entire section of a level with the inside of a function PhotonNetwork.Instantiate OnCreatedRoom (). Appears Labyrinth for some time when you create a room, then he disappears (in the hierarchy do not have it too). I guess there is a more efficient way to create a multiplayer game with procedural levels (perhaps creating a labyrinth at the time the rooms and obtain information about the maze at the entrance to the room?). Could you please advise - in which direction should I dig?

thanks in advance

Comments

  • Adding PhotonViews for every tile is very inefficient.

    The best option would be to Serialize the generation of this maze into some data format.
    E.g. you could make a function to export the generated maze to a text format, and have other clients import this

    E.g:
    XXXXXXX
    XOOOOOX
    XOXOXOX
    XOOOOOX
    XXXXXXX
    

    Then, after the first client (the master client) has generated this maze, send it using a OtherBufferred RPC message so that all future clients will receive this message. Or even better is to have the masterclient send it's current level to new clients when they connect. (Buffered RPC messages will be cleared if that player leaves)
  • Leepo wrote:
    masterclient send it's current level to new clients when they connect. (Buffered RPC messages will be cleared if that player leaves)
    As I expected. Thank you. Hmm, I will need to create a data structure that reflects the structure of the maze.
    Is there an example in code? Data transfer between the master client and the client in a cloud or something like that?
  • Is there an example in code? Data transfer between the master client and the client in a cloud or something like that?
    void Awake(){
    if(PhotonNetwork.isMasterClient){ //We are the master client
    //generate the maze
    ...
    //output the maze to (for example) text format
    string textFormat= GetMazeOutput();
    //Send the maze to other clients
    photonView.RPC("SetLevelData", PhotonTargets.OthersBuffered,textFormat);
    }
    }
    
    [RPC]
    void SetLevelData(string importMaze){
    ImportMaze(importMaze);
    }
    
    
  • Leepo wrote:
    [RPC]
    void SetLevelData(string importMaze){
    
    }
    

    Thank you. It worked well.
    But there is one small problem. If the first master-client will leave the room, the point where running RPC createMaze otherbuff, will cease to exist. Because of this, new players join the room does not receive data on the structure of the maze. The client, which will turn into the master-client does not comply with this part of the code. Because it is inside a function Awake the first master-client. If you force it to comply with RPC createMaze otherbuff at OnMasterClientSwitched, clients who already have all the information about the maze, will receive a copy of the unwanted.

    If I described the situation is unclear, try to reproduce it: you have to run the application, create a room. Then, run the application in another window, go into the room. At this point, two players have the same maze and see each other, all is well. Then, you need to leave the room the first player. Then try again to join the still existing room. You will see a black box - data on the maze can not be obtained.

    Any ideas how to gracefully handle this situation? Close the room when the first master-client will be released? But it kind of sad. Negates the benefits of working in the cloud.
  • The master client will be switched to client nr 2 (or whatever available nr). Since this client should have already received the level, it can simply take over from the previous master client. It has the level data too, so there should be no problems with switching the MC.
Sign In or Register to comment.