I am using Photon with cocos2dx for making a multiplayer game. When I create room from one player, it creates room successfully and after 4 or 5 seconds when I join room from other player then both player join each other successfully and game starts. The problem comes when I start game from both sides together, both players thinks that there is no room exist they both create their own rooms and unable to join each other.
Thanks in advance.
You might want to use opJoinRoom, setting createIfNotExiststo true.
Doing so will have the first player create the room and the second one joining in.
Related
I'm new to Game Development. I'm creating a multiplayer game using Unity, Playfab and Photon. I'm doing matchmaking in Playfab and room creation in Photon. In Playfab I have a matchmaking queue with a max player and min player set as 2.
On running the game I can see that when 2 players log in and start the matchmaking process everything is fine and the players can play the game. But the problem is when 4 players join the game with 4 different devices (so 4 instances of the game) and try to start the match simultaneously.
The expected behaviour is when 4 players start the game simultaneously 2 rooms should be created with 2 players each and start the game. But what is happening, only 1 set of players is able to play the game and the other set of players are not able to.
I'm checking PhotonNetwork.CurrentRoom.PlayerCount is equal to 2 to start the game. when 2 players join the room it is working fine.
but when another 2 players try to play the game simultaneously while another match is going on, the master player is able to join the match but the second player is not joining and PhotonNetwork.CurrentRoom.PlayerCount is always equal to 1 for the second set of players.
while (PhotonNetwork.CurrentRoom.PlayerCount != 2)
{
Debug.Log("Player Count: " + PhotonNetwork.CurrentRoom.PlayerCount);
yield return null;
}
//After players join logic
I tried my best to explain the issue. please feel free to ask for any additional info on this. any amount of help will be much appriciated. Thank you
I'm making my own match 3 multiplayer game, the concept is to have two people face off against each other person can face off another person by swapping tiles to make a line of the same form. I want to introduce multiplayer by connecting two players together and allowing each person to see their opponent's screen, as well as syncing their moves. So far, I have a simple match 3 game (I created one using different tutorials, mainly this playlist) and followed a simple multiplayer tutorial (Mirror) for a player to host or be a client. My problem is that I have no idea how to show both players their opponent's screen to each other. I even found an example of what I want the multiplayer mode in my game to be like. Can anyone point me in the right direction, please and thank you.
Additional information:
I'm using mirror for multiplayer
I created a network manager gameobject and added the necessary components to it. I also added the game pieces into the 'registered spawnable prefabs' and created an empty gameobject, called player for the player prefab.
Each game piece has a network transform and network identity component attached.
The player prefab object has a camera child under it to.
This is what I want my game to look like:
Overall, I want to have player's view each other's screen:
As you can see, both player's are connected, what I want to do it to allow each player see their opponent's screen. Does anyone have an idea on how I can do it?
Thank you! :)
Hey guys,
As soon as a certain number of players is reached, a random player is selected and the "CatcherPlayerController" is assigned to him. All other players keep the standard PlayerController.
How do I get all players only with the standard PlayerController and respawn them at different points? The whole thing is for a waiting lobby system in which all players, except the "catcher", have to be respawned as soon as the game starts.
I've tried several approaches but haven't found a solution yet. Thanks in advance!
You could iterate over all players and get the player controller, try to cast it to CatcherPlayerController and if it fails you know it's a standard PlayerController. Since it's a once in bluemoon event I would not be worried about performance issues of all the cast you should do but it really depends on the number of players. Let me know more if I misunderstood your problem.
How can I synchronize scenes of all players according to the first player who created the room?
Specifically. The items will be randomly generated on the creator's scene. All guests entering the room will sync.
You can use custom room properties for that, where you define all these random elements final state, and players joining the room, will read these custom properties and reproduce these elements as described in the room properties. Players currently in the room can listen to room property change callback and adjust realtime.
doc: https://doc.photonengine.com/en-us/pun/v2/gameplay/synchronization-and-state#custom_properties
I have one big problem with PUN, and that is that PhotonNetwork.Instantiate instantiates objects on a per-room basis, not a per-scene basis. The setup I have right now is one "server", the master client, and then everyone else joins the same room. This is because I need to be able to send RPC calls to the server before gameplay, for login and character creation purposes.
The problem with this is that players already in the world will show up in the login and character creation scene of any new player's client, and will disappear when the player changes scenes. Ideally, I would like to only instantiate the players that are in the same scene as the client, but I have no idea how to do this.
Any help would be greatly appreciated.
Call PhotonNetwork.Instantiate when all the users are present in the game scene.
Before starting game check if all the players have successfully loaded the game scene. If acknowledgment is received from every player than call PhotonNetwork.Instantiate and start the game.