public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if(stream.isWriting)
{
// this is my player. need to send my actual position to the network
stream.SendNext(transform.position);
stream.SendNext(_charController.velocity);
stream.SendNext(transform.rotation);
}
else
{
//this is another player. need to get his position data. then update my version of this player
Vector3 syncPosition = (Vector3)stream.ReceiveNext();
Vector3 syncVelocity = (Vector3)stream.ReceiveNext();
syncEndRotation = (Quaternion)stream.ReceiveNext();
syncStartRotation = transform.rotation;
syncTime = 0f;
syncDelay = Time.time - lastSynchronizationTime;
lastSynchronizationTime = Time.time;
syncEndPosition = syncPosition + syncVelocity * syncDelay;
syncStartPosition = transform.position;
}
}