InvalidCastException: Cannot cast from source type to destination type (Photon version : 1.91)

Hi,
i got this error when using WebGl only , my game works fine with no errors (standalone PC Build) , but when i use WebGl build and test i got this :
InvalidCastException: Cannot cast from source type to destination type. NetworkingPeer.AlmostEquals (System.Object one, System.Object two) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:4567) NetworkingPeer.DeltaCompressionWrite (System.Object[] previousContent, System.Object[] currentContent) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:4416) NetworkingPeer.OnSerializeWrite (.PhotonView view) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:4302) NetworkingPeer.RunViewUpdate () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:4118) PhotonHandler.Update () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:165)
i don't know is this Unity or Photon issue and i don't know what data else i can provide here , tell me and i will edit this question with new data

Best Answer

  • AhmedGobaAhmedGoba
    Accepted Answer
    i solved this problemby changing the two lines at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:(4566 , 4567) :
    from
    float a = (float)one;
    float b = (float)two;
    to
    float a = Convert.ToSingle(one);
    float b = Convert.ToSingle(two);

    yes it was casting problem

Answers

  • sorry i foregt to mention that this error happenes only when any other player joins the room and it appears forever
  • AhmedGobaAhmedGoba
    Accepted Answer
    i solved this problemby changing the two lines at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:(4566 , 4567) :
    from
    float a = (float)one;
    float b = (float)two;
    to
    float a = Convert.ToSingle(one);
    float b = Convert.ToSingle(two);

    yes it was casting problem
  • Thank you so much, this saved my sanity and game!
Sign In or Register to comment.