Quantcast
Channel: Photon Unity Networking (PUN) — Photon Engine
Viewing all articles
Browse latest Browse all 8947

OnPhotonSerializeView() Vector3s looking like Vector4s

$
0
0
Hello,

I'm having problems passing a Vector3 through photon. Essentially we are sending a Vector3, followed by a Float through OnSerliezeView. On the receive end we are getting a Vector4 and thus having a casting issue because we are expecting a Vector3.

We have since moved the Float to before the Vector3 send as denoted below and it seems like it is working fine now.

if (stream.isWriting)
{
stream.SendNext(colliders.localRotation.eulerAngles.y);
stream.SendNext(carRigidbody.position);
stream.SendNext(carRigidbody.velocity);
stream.SendNext(new Vector3(carRigidbody.rotation.eulerAngles.x, carRigidbody.rotation.eulerAngles.y, carRigidbody.rotation.eulerAngles.z));

}
else
{
PacketInfo packet;
packet.mTime = info.timestamp;
packet.mDriftAngle = (float)stream.ReceiveNext();
packet.mPosition = (Vector3)stream.ReceiveNext();
packet.mVelocity= (Vector3)stream.ReceiveNext();
Vector3 EulerAngles = (Vector3)stream.ReceiveNext();

packet.mRotation = Quaternion.EulerAngles(EulerAngles);

Viewing all articles
Browse latest Browse all 8947

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>