Hey guys,
So I’m using Photon for a coop 2D shmup, and I’ve (finally) managed to smooth out the movement. But another problem that has plagued me for a while is that the positions don’t quite match up for the players. For example, on one version I have running I am ahead, whereas on the other they are ahead. I am wanting to implement colliders, which is pretty confusing when you don’t know where the other player is.
Any hint as to what I’m doing wrong would be great. This is the code for the players being networked (its pretty standard):
The code
void Update () {
if(photonView.isMine) {
}
else {
transform.position = Vector3.Lerp(transform.position, realPosition, Time.deltaTime * 5);
}
}
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
if(stream.isWriting) {
stream.SendNext (transform.position);
}
else {
realPosition = (Vector3)stream.ReceiveNext();
}
}
I am also moving a camera over the network, but that has an almost identical script.
Currently, everything is on Unreliable on change. Changing that didn’t seem to have any effect on the outcome. Also, every window i view the game on is the same resolution.
Thanks a lot,
Danny