Where and how to store scene information and how to make the level change when the round is over

Options
Hello everyone, my first time posting here so apologies if this has already been asked before but im just getting used to photon networking and im currently implementing it into my game. At present i have created a single scene which multiple players can join and control their own characters and have also fixed the interpolation and animation of the players which was quite a hassle.

I did this using the scripts from the 2d platformer demo, which utilizes the CreateAndJoinRandom script and the OnJoinedInstantiate script, which if im reading the script correctly will connect to the network and load the same scene using...

PhotonNetwork.ConnectUsingSettings(Version + "."+Application.loadedLevel);,

after this it will attempt to join a room using PhotonNetwork.JoinRandomRoom(); and if one isnt available it will create one using PhotonNetwork.CreateRoom(null, new RoomOptions() { maxPlayers = 4 }, null);

so i understand the basic process of how this works but im having trouble grasping how im going to do a few essential things, and all the photon demos and youtube tutorials never seem to go into how to do this, I thought id ask you guys first as reading through the complete PhotonNetwork script is quite overwhelming, any information you guys can give me on any of these problems would be much appreciated

I need to create a main menu where players can attempt to start a game, when they load the game this connects to the network and shows the other players in the rooms (if there are any), when at least 2 players have joined the network a game can be loaded (either automatically or remotely by voting or something), this will then create a room which the players join but also load a scene, the players should be on opposite teams and therefore spawn in different locations (i think i can figure out how to do this with the main manager), now other players who enter the game should be able to see the current games available and join it, which will load the scene the room is using. Now when the players finish a round in the current scene (i.e, one of the team wins the round) it loads a new scene and all the players in the current room join it. likewise if people in the main menu join the room it will load the correct scene.

So how exactly should i go about storing the scene and room information, how exactly do i tie them together, and how should i go about loading a random scene when a level is beat, sorry for the long read, hope i explained my problem clearly enough, and any information would be greatly appreciated as i havnt found a single tutorial on anything like this. thanks

Comments

  • Tobias
    Options
    If you append the level to the Version of your app, this will separate your users. Each GameVersion is a separate, virtual app and only players with the correct level will find each other potentially.

    Did you have a look at PhtonNetwork,LoadLevel()?
    Also, have a look at the demo with Teams, Score, etc.

    I have to admit, I am rushing over your post, as it's rather long and seems to be along the lines of "I didn't read the existing material, help me with X". We are not able to do that, I fear, out of sheer amount of work to do. Sorry.
    Let me know when you need a pointer to anything in particular.
  • Dev_Skeletal
    edited November 2015
    Options
    Hello, thanks for the reply, your right i probably didnt read the existing material enough, i eventually went over the worker demo and used that to make a multiplayer menu, the problem im mainly having is storing information for the room

    To explain in as short a way as possible ive created a singleton script which is instantiated to the scene only once when a player joins a room using PhotonNetwork.InstantiateSceneObject, im using this script to store information about the game however though the script can be viewed and accessed by anyone over the network the only player which can change any information on the script is the MasterClient.

    All i really want is a singleton script in the scene which each player can alter (in this place by pressing a button a player can increase an int) which i can use to start the game, any ideas would be appreciated

    [EDIT] Been looking into it more and ive figured out the problem, i wasnt setting a new owner with TransferOwnership(PhotonNetwork.player.ID); it works now but im having an issue where the ownership isnt getting transfered right away and the integer increase happening right after it isnt always registering as it still belongs to the last owner, is there any way to make it owned or accessible by all players without switching the owner constantly?