- Home /
Question by
beeboks · Jul 23, 2016 at 07:49 PM ·
networkingphotonpositioningbuffer
What is the best way to get exact positional and other data through Photon networking?
Hi, I'm new to networking and creating networked games. I'm trying to get position and rotation data through Photon and I'm currently interpolating position through the incoming stream
void Update()
{
if (!photonView.isMine)
{
timeToReachGoal = currentPacketTime - lastPacketTime;
currentTime += Time.deltaTime;
transform.position = Vector3.Lerp(positionAtLastPacket, realPosition, (float)(currentTime / timeToReachGoal));
}
}
void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
stream.SendNext((Vector3)transform.position);
}
else
{
currentTime = 0.0;
positionAtLastPacket = transform.position;
realPosition = (Vector3)stream.ReceiveNext();
lastPacketTime = currentPacketTime;
currentPacketTime = info.timestamp;
}
}
But a lot of the subtlety of the motion is destroyed through the interpolation.
Is there a way to get every frame of data through even if that data is buffered and drags behind by several seconds, as long as it plays back on the other PC practically exactly as it played on the original PC?
Comment