Photon Unity Networking Unwanted Cross-scene Instantiation - unity3d

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.

Related

How to spawn an object only for a specific client using Unity Mirror?

NetworkServer.Spawn method spawns a gameobject, instantiated on server, to all clients. I have a canvas with UI for player. UI communicates with server through commands and RPCs. This canvas makes sense only to local player. There is no point in having these canvases instantiated on each player on client side. I`m trying to come up with a way to spawn one canvas for each player.
I`ve come across a suggestion to carry the canvas as disabled child object of player prefab and enable it with isLocalPlayer check. But I think that this solution is suboptimal for a type of game with loads of players.

How to access component of a player from instantiated object in PUN 2

I'm trying to learn Photon networking in Unity and ran into a bit of a problem. My player object has a script that instantiates GrenadeObject. Grenade object then has yet another script that deals with OnCollisionDetection and instantiates GroundObject when it touches floor.
Everything's working fine but now I started implementing teams into a game and it turned out to be a little bit tricky. Information about which team certain player is are stored in the GameSettings script that is also attached to a player object. I need to access those information from GroundObject and I'm not sure how to do that. I tried many things but always got NullReferenceException.
Furthest I could get is accessing my GrenadeObject that (as it seems) is owner of GroundObject. I'm assuming something like that is possible since autoCleanUpPlayerObjects removes all GroundObjects intantiated by that player when he leaves. What can I try next?

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

Why is the NetworkIdentity component making my Game Object invisible? (Unity)

Currently trying to make a multiplayer snake game, I have never made a multiplayer game before. I am having a very strange issue where whenever I add the NetworkIdentity component to my 'Snake' game object, it becomes invisible, but is still there. The game is still functional; you just can't see the snake.
I have two pictures attached, one is the game with the NetworkIdentity component, one is the game without it. Thank you for the help.
Without component
With component
A) your image labels seem to be flipped .. exchange the Without and With ;)
and B) Afaik this is the expected behavior for any GameObject with a NetworkIdentity as long as you are not connected to any network yet. It will get enabled once you host or join a session.
You probably would rather convert this into the player prefab though and not have it in your scene from the beginning but rather let the NetworkManager automatically spawn it for every player in the session including yourself.

Unity Photon Player Instantiation

I have a SteamVR Unity project which I'm converting to multiplayer.
When another client joins the game, instead of two different players seeing each other, each player has it's own version of the game where he controls all fo the player instances.
For example, while one player is connected everything is fine, but when a second player joins, the game just adds another Player prefab which the first player controls as well.
I tried replacing the Player with a simple cube and everything seems fine.
both the Player and the cube have Photon Transform View and Photon View scripts.
I would appreciate any help I can get.
This is a common problem, when you start with PUN. You probably setup a player prefab with network synchronization and instantiate that for each player. All scripts on the instances will act on the local input, which is what you see now.
You want two variants of the prefab, for local and remote representation. As it's impractical to always configure two prefabs, instead you build one which initializes itself (in Awake or Start) as local or remote. Your scripts should check the object's PhotonView if it's .isMine or not.
This can be done per Component (in each distinct script) or you could add a component which enables/disables the scripts on a GameObject, depending on isMine.
The Basics Tutorial does this, for example.
Unity doesn't know if it's multiplayer or not. When you give an input all of the scripts who are waiting for input takes it and behaves accordingly. To solve this basically create another player that doesn't take any input and spawn it for other players.