- Home /
Photon only host changes sync
I'm trying out photon for the first time. I work with vuforia and a marker. A cube spawns on the marker and you can move it with a canvas button.
Whenever the host clicks the button, the other player can also see the changes. But when the player clicks the button it moves for a second and then goes back. At my host their screen you can't see any movement done by the player.
Are there good tutorials to simply sync changes with photon? (it's on android)
Here's a simple script to try it out, which I'm using atm:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class Change : MonoBehaviour, IPunObservable
{
public void buttonpress()
{
transform.position = new Vector3(transform.position.x, transform.position.y + .5f, transform.position.z);
}
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.IsWriting)
{
stream.SendNext(transform.position);
}
else if (stream.IsReading)
{
transform.position = (Vector3)stream.ReceiveNext();
}
}
}
Comment