Error when taking over ownership for the first time.
Options
Estecka
✭
I have a scene with a non-prefab PhotonView, with ownership set as takeover.
The first time a connected player tries to take ownership over it, Photon will throw an error on every connected clients.
The error is the same for every clients :
The code I use to get this error are as simple as this :
Lobby scene :
Unity version : 2018.3.14f1
PUN version 2.10 Photon lib 4.1.2.12
Reproductions steps :
- Create a new Unity project, import PUN 2, then import this Unity Package : https://filebin.net/8xe9xfxb0v0atr1r
- In the build settings, add the scenes "Lobby" at 0 and "Room" at 1
- In the PhotonServer setting, set a fixed region. (Just to make sure two clients will always connect together.
- Make a standalone Debug build with Script debugging and run it. (Making it the master)
- Once the scene with The Cube has loaded in the build, run the "Lobby" scene in the editor.
- Once the scene with The Cube has loaded in the editor, click The Cube to assume ownership.
=> Both the Build and Editor will display an error.
The first time a connected player tries to take ownership over it, Photon will throw an error on every connected clients.
The error is the same for every clients :
NullReferenceException: Object reference not set to an instance of an object
Photon.Pun.PhotonNetwork.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:2157)
Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2749)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PeerBase.cs:633)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:550)
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1473)
Photon.Pun.PhotonHandler.FixedUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:116)
Photon.Pun.PhotonNetwork.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:2157)
Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2749)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PeerBase.cs:633)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:550)
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1473)
Photon.Pun.PhotonHandler.FixedUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:116)
The code I use to get this error are as simple as this :
Lobby scene :
using UnityEngine; using Photon.Pun; using Photon.Realtime; public class Lobby : MonoBehaviourPunCallbacks { void Start(){ PhotonNetwork.AutomaticallySyncScene = true; PhotonNetwork.ConnectUsingSettings(); } public override void OnConnectedToMaster(){ PhotonNetwork.JoinOrCreateRoom("room" , null, TypedLobby.Default); } public override void OnCreatedRoom(){ PhotonNetwork.LoadLevel("Room"); } }Room scene :
using UnityEngine; using UnityEngine.EventSystems; using Photon.Pun; public class TakeOver : MonoBehaviour, IPointerClickHandler { public PhotonView photon; void IPointerClickHandler.OnPointerClick(PointerEventData eventData){ if (!photon.IsMine) { Debug.Log("Mine !"); photon.TransferOwnership(PhotonNetwork.LocalPlayer); } } }Did I miss something important ?
Unity version : 2018.3.14f1
PUN version 2.10 Photon lib 4.1.2.12
Reproductions steps :
- Create a new Unity project, import PUN 2, then import this Unity Package : https://filebin.net/8xe9xfxb0v0atr1r
- In the build settings, add the scenes "Lobby" at 0 and "Room" at 1
- In the PhotonServer setting, set a fixed region. (Just to make sure two clients will always connect together.
- Make a standalone Debug build with Script debugging and run it. (Making it the master)
- Once the scene with The Cube has loaded in the build, run the "Lobby" scene in the editor.
- Once the scene with The Cube has loaded in the editor, click The Cube to assume ownership.
=> Both the Build and Editor will display an error.
0