Partial Send OnPhotonSerializeView
Hi:
I am using OnPhotonSerializeView to sync player position/Rotation, hands State/Position/Rotation at the same time.
I sometimes see InvalidCastException: Specified cast is not valid. over the line
Thanks.
Full OnPhotonSerializeView is as follow:
I am using OnPhotonSerializeView to sync player position/Rotation, hands State/Position/Rotation at the same time.
I sometimes see InvalidCastException: Specified cast is not valid. over the line
charComponent.SyncLeftHandIKEnable = (bool)stream.ReceiveNext();Just wondering if I am correctly using OnPhotonSerializeView .
Thanks.
Full OnPhotonSerializeView is as follow:
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.IsWriting) { if (charComponent.DisableSync) // ghost mode return; // Always Transfer SyncLeftHandIKEnable stream.SendNext(charComponent.SyncLeftHandIKEnable); if (!charComponent.SyncLeftHandIKEnable) return; stream.SendNext(charComponent.SyncLeftHandPosition); stream.SendNext(charComponent.SyncLeftHandRotation); stream.SendNext(charComponent.SyncLeftHandGesture); } else { charComponent.SyncLeftHandIKEnable = (bool)stream.ReceiveNext(); if (!charComponent.SyncLeftHandIKEnable) return; charComponent.SyncLeftHandPosition = (Vector3)stream.ReceiveNext(); charComponent.SyncLeftHandRotation = (Quaternion)stream.ReceiveNext(); charComponent.SyncLeftHandGesture = (GestureIndex)stream.ReceiveNext(); } }
1
Comments
-
yeah, i get the invalid cast, usually when transitioning to a new scene. it's almost like photon ids get swapped and then late messages from the previous scene show up that aren't meant for that photon view.0