BUG in PUN: Specified cast is not valid
We have a project that uses PUN to play multiplayer in Unity. At first we tried the free version and were able to work. But once we move on to the full plugin, we get stuck in the login stages. Attach the errors in the console.
We will be happy for a solution.
Thanks
THE ERRORS:
InvalidCastException: Specified cast is not valid.
Photon.Pun.UtilityScripts.CountdownTimer.TryGetStartTime (System.Int32& startTimestamp) (at Assets/Photon/PhotonUnityNetworking/UtilityScripts/Room/CountdownTimer.cs:153)
Photon.Pun.UtilityScripts.CountdownTimer.Initialize () (at Assets/Photon/PhotonUnityNetworking/UtilityScripts/Room/CountdownTimer.cs:123)
Photon.Pun.UtilityScripts.CountdownTimer.OnRoomPropertiesUpdate (ExitGames.Client.Photon.Hashtable propertiesThatChanged) (at Assets/Photon/PhotonUnityNetworking/UtilityScripts/Room/CountdownTimer.cs:116)
Photon.Realtime.InRoomCallbacksContainer.OnRoomPropertiesUpdate (ExitGames.Client.Photon.Hashtable propertiesThatChanged) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:4027)
Photon.Realtime.LoadBalancingClient.ReadoutProperties (ExitGames.Client.Photon.Hashtable gameProperties, ExitGames.Client.Photon.Hashtable actorProperties, System.Int32 targetActorNr) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2070)
Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3077)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at <a497a6f18e1f4b419421b940add27a6e>:0)
ExitGames.Client.Photon.TPeer.DispatchIncomingCommands () (at <a497a6f18e1f4b419421b940add27a6e>:0)
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at <a497a6f18e1f4b419421b940add27a6e>:0)
Photon.Pun.PhotonHandler.Dispatch () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:208)
Photon.Pun.PhotonHandler.FixedUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:142)
We will be happy for a solution.
Thanks
THE ERRORS:
InvalidCastException: Specified cast is not valid.
Photon.Pun.UtilityScripts.CountdownTimer.TryGetStartTime (System.Int32& startTimestamp) (at Assets/Photon/PhotonUnityNetworking/UtilityScripts/Room/CountdownTimer.cs:153)
Photon.Pun.UtilityScripts.CountdownTimer.Initialize () (at Assets/Photon/PhotonUnityNetworking/UtilityScripts/Room/CountdownTimer.cs:123)
Photon.Pun.UtilityScripts.CountdownTimer.OnRoomPropertiesUpdate (ExitGames.Client.Photon.Hashtable propertiesThatChanged) (at Assets/Photon/PhotonUnityNetworking/UtilityScripts/Room/CountdownTimer.cs:116)
Photon.Realtime.InRoomCallbacksContainer.OnRoomPropertiesUpdate (ExitGames.Client.Photon.Hashtable propertiesThatChanged) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:4027)
Photon.Realtime.LoadBalancingClient.ReadoutProperties (ExitGames.Client.Photon.Hashtable gameProperties, ExitGames.Client.Photon.Hashtable actorProperties, System.Int32 targetActorNr) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2070)
Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3077)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at <a497a6f18e1f4b419421b940add27a6e>:0)
ExitGames.Client.Photon.TPeer.DispatchIncomingCommands () (at <a497a6f18e1f4b419421b940add27a6e>:0)
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at <a497a6f18e1f4b419421b940add27a6e>:0)
Photon.Pun.PhotonHandler.Dispatch () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:208)
Photon.Pun.PhotonHandler.FixedUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:142)
0
Comments
public static bool TryGetStartTime(out int startTimestamp)
{
startTimestamp = PhotonNetwork.ServerTimestamp;
object startTimeFromProps;
//int startTimeFromProps;
if (PhotonNetwork.CurrentRoom.CustomProperties.TryGetValue(CountdownStartTime, out startTimeFromProps))
{
startTimestamp = (int)startTimeFromProps;
return true;
}
return false;
}
If I delete this line:
"startTimestamp = (int)startTimeFromProps;"
the game starts well.
Maybe change the value of CountdownStartTime = "StartTime". This propery may be used by your code for something non-integer.