PhotonTransformView gets an InvalidCastException

I just downloaded PUN2 and went through the PUN Basics Tutorial. I'm using Unity 2020.2.0f1. When I tried running the demo after implementing everything, my standalone build would get the following error whenever I moved or fired the lasers in the editor.
InvalidCastException: Specified cast is not valid.
  at Photon.Pun.PhotonTransformView.OnPhotonSerializeView (Photon.Pun.PhotonStream stream, Photon.Pun.PhotonMessageInfo info) [0x0013e] in O:\dev\projects\VR Photon Test\Assets\Photon\PhotonUnityNetworking\Code\Views\PhotonTransformView.cs:124 
  at Photon.Pun.PhotonView.DeserializeComponent (UnityEngine.Component component, Photon.Pun.PhotonStream stream, Photon.Pun.PhotonMessageInfo info) [0x00011] in O:\dev\projects\VR Photon Test\Assets\Photon\PhotonUnityNetworking\Code\PhotonView.cs:616 
  at Photon.Pun.PhotonView.DeserializeView (Photon.Pun.PhotonStream stream, Photon.Pun.PhotonMessageInfo info) [0x0003c] in O:\dev\projects\VR Photon Test\Assets\Photon\PhotonUnityNetworking\Code\PhotonView.cs:606 
  at Photon.Pun.PhotonNetwork.OnSerializeRead (System.Object[] data, Photon.Realtime.Player sender, System.Int32 networkTime, System.Int16 correctPrefix) [0x0019e] in O:\dev\projects\VR Photon Test\Assets\Photon\PhotonUnityNetworking\Code\PhotonNetworkPart.cs:1860 
  at Photon.Pun.PhotonNetwork.OnEvent (ExitGames.Client.Photon.EventData photonEvent) [0x00111] in O:\dev\projects\VR Photon Test\Assets\Photon\PhotonUnityNetworking\Code\PhotonNetworkPart.cs:2231 
  at Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) [0x00524] in O:\dev\projects\VR Photon Test\Assets\Photon\PhotonRealtime\Code\LoadBalancingClient.cs:3284 
  at ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) [0x002e1] in D:\Dev\Work\photon-dotnet-sdk\PhotonDotNet\PeerBase.cs:891 
  at ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () [0x003af] in D:\Dev\Work\photon-dotnet-sdk\PhotonDotNet\EnetPeer.cs:559 
  at ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () [0x00034] in D:\Dev\Work\photon-dotnet-sdk\PhotonDotNet\PhotonPeer.cs:1837 
  at Photon.Pun.PhotonHandler.Dispatch () [0x0002b] in O:\dev\projects\VR Photon Test\Assets\Photon\PhotonUnityNetworking\Code\PhotonHandler.cs:223 
  at Photon.Pun.PhotonHandler.FixedUpdate () [0x00012] in O:\dev\projects\VR Photon Test\Assets\Photon\PhotonUnityNetworking\Code\PhotonHandler.cs:149 

(Filename: O:/dev/projects/VR Photon Test/Assets/Photon/PhotonUnityNetworking/Code/Views/PhotonTransformView.cs Line: 124)

I looked at the code, and everything looked like it was de/serializing in order. Since I'm new to using PUN2 and haven't spent much time playing around with it, I ended up switching to a PhotonTransformViewClassic, and it works now. So, for some weird reason the new version of PhotonTransformView is throwing this exception. Just thought you might want to know.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @OutOfMyMindDave,

    Thank you for choosing Photon and for your report!

    What PUN 2 version is this?
    When you try the PUN Basics Tutorial or Asteroids demos scenes that are provided in the package, can you reproduce?
    Did you modify PhotonTransformView or any other PUN 2 code?
  • I went through the basics tutorial with a clean project. I'm using PUN2 version 2.28.3. I was not able to repro the bug with the PunBasics-Tutorial demo, and I had not seen that. I can compare it to my project and figure out where I went wrong. Thanks!