PUN 2 and Playfab multiplayer joining issue when more that 2 players play the game - unity3d

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

Related

Sharing one camera with multiple Players

I want to create a simple multiplayer game in unity 3d using photon pun 2 free.
Im trying to implement a shared camera, a camera that doesnt follow any Player, stays stationary and everyone sees the same thing.
I ve run into the issue where Only the master client sees the changes and other clients have the scene frozen As if the camera didnt update for them at all
So how to fix that, how to make the camera update for everyone not just the host?

Unity2D: Mirror Multiplying - How to view an opponent's screen in a match 3 game

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! :)

How do I respawn all players of a particular player controller in ue4?

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.

Different models of clients and other players in Unity

I am working on online FPS like Counter-Strike and overwatch.
In such games player can se only hands of their character, while other players can see full model.
How to realize it in unity?
Hope you got what I mean.
Online multiplayer is an illusion.
You have to sync the game state between all players and visually show different things depending on if a player is the local player.
if(localPlayer) {
// spawn hands with the gun
} else {
// spawn the full player model
}

Photon Multiplayer, Both players create their own rooms

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.