"InvalidCastException: Specified cast is not valid." when using PhotonTransformView (Pun 2.7)
olistan
✭
Hello,
I simply added a PhotonTransformView to a prefab that is instantiated with Photon and it causes the following error in Unity's Console (at runtime):
Maybe this is because the level prefix is sent as a byte, but read as a short?
PS: I also dragged and dropped the PhotonTransformView component to the list of observed components of the PhotonView.
Edit: If I avoid using SetLevelPrefix() then the error disappears and my objects are synchronized.
I simply added a PhotonTransformView to a prefab that is instantiated with Photon and it causes the following error in Unity's Console (at runtime):
And the instantiated objects aren't synchronised on both clients.
InvalidCastException: Specified cast is not valid.
Photon.Pun.PhotonNetwork.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Tools/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:2018)
Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Tools/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2579)
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:545)
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1473)
Photon.Pun.PhotonHandler.FixedUpdate () (at Assets/Tools/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:130)
Maybe this is because the level prefix is sent as a byte, but read as a short?
PS: I also dragged and dropped the PhotonTransformView component to the list of observed components of the PhotonView.
Edit: If I avoid using SetLevelPrefix() then the error disappears and my objects are synchronized.
0
Comments
-
Hi @olistan,
This looks like a bug yes.
Can you replace line 2018 of "Assets\Photon\PhotonUnityNetworking\Code\PhotonNetworkPart.cs"?short remoteLevelPrefix = (pvUpdates[1] != null) ? (short)pvUpdates[1] : (short)0;
withshort remoteLevelPrefix = (pvUpdates[1] != null) ? (byte)pvUpdates[1] : (short)0;
0