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

PhotonView sending updates despite no change

$
0
0
Hi!
I have a GameObject with a PhotonView observing the script below. The PhotonView Observe Option is set to "Unreliable On Change". I've also tried "Reliable Delta Compressed". In both cases, the transform position and rotation are being spammed out from the master client to all other clients, despite not changing. Its a little bit magic to me how PhotonView's can tell which data is the data to trigger updates on, so maybe my lack of understanding there is the problem.

Thanks for any and all help. :)

-tim

Here is my amazing, totally-not-copied-from-the-viking-tutorial script:

public class NetworkCharacter : Photon.MonoBehaviour
{

private Vector3 correctPlayerPos;
private Quaternion correctPlayerRot;
bool appliedInitialUpdate;

void Awake()
{
appliedInitialUpdate = false;
}

void Update()
{
if (!photonView.isMine)
{
transform.position = Vector3.Lerp(transform.position, this.correctPlayerPos, Time.deltaTime * 5);
transform.rotation = Quaternion.Lerp(transform.rotation, this.correctPlayerRot, Time.deltaTime * 5);
}
}

public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
GameController.instance.TimedLog ("NetworkCharacter sending message to client for GameObject " + gameObject.name + ", position " + transform.position + " and rotation " + transform.rotation);

// We own this player: send the others our data
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
}
else
{
GameController.instance.TimedLog ("NetworkCharacter receiving message from server for GameObject " + gameObject.name + ", position " + transform.position + " and rotation " + transform.rotation);

// Network player, receive data
this.correctPlayerPos = (Vector3)stream.ReceiveNext();
this.correctPlayerRot = (Quaternion)stream.ReceiveNext();

if (!appliedInitialUpdate)
{
appliedInitialUpdate = true;
transform.position = correctPlayerPos;
transform.rotation = correctPlayerRot;
UnitMovement movement = GetComponent<UnitMovement> ();
Debug.Assert (movement);
movement.TeleportToLocalPosition (correctPlayerPos);

}
}
}

}

Viewing all articles
Browse latest Browse all 8947

Trending Articles



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