- Home /
RPC a lot of lags (Photon)
Hi! I tried to create multiplayer scene using Photon, where a two players moving a box. But there is a lot of lags while they doing it. I used a RPC to sync position.
using UnityEngine;
using System.Collections;
public class boxNetwork : Photon.MonoBehaviour {
Quaternion rotation1;
occupedBox ocBox;
Vector3 position1;
void Start() {
oldPos = transform.position;
ocBox = this.GetComponent<occupedBox>(); //the bool value when a players pick up a box
}
void Update ()
{
if (ocBox.isOccuped) {
photonView.RPC("SendMovement",PhotonTargets.AllBuffered, position1, rotation1);
} else {
position1 = gameObject.transform.position;
}
}
[RPC]
void SendMovement(Vector3 position1, Quaternion rotation1)
{
gameObject.transform.position = position1;
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613101649im_/https://answers.unity.com/themes/thub/images/avi.jpg)