- Home /
Players are lagging in Photon multiplayer
Hey,
the player movement is lagging in a multiplayer room using Photon. So I want to have a smooth player movement.
I've tried this code already:
public class SyncAnimations : Photon.MonoBehaviour {
Vector3 realPosition = Vector3.zero;
Quaternion realRotation = Quaternion.identity;
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
}
else
{
realPosition = (Vector3)stream.ReceiveNext();
realRotation = (Quaternion)stream.ReceiveNext();
}
}
void Update () {
if(photonView.isMine)
{
//Do nothing
}
else
{
transform.position = Vector3.Lerp(transform.position, realPosition, 0.1f);
transform.rotation = Quaternion.Lerp(transform.rotation, realRotation, 0.1f);
}
}
But the players are invisible then and when they are at a certain position, the're visible, while they're moving.
I'm working on this for a while already, can anybody help me, please?!
Did you take a look at the Synchronization Demo co$$anonymous$$g with the PUN package from the Asset Store? Was non of these synchronization algorithms satisfying?
Your answer
Follow this Question
Related Questions
How can I add jumping to my multiplayer photon script? 0 Answers
Photon Player Controls Other Player 0 Answers
Player Smoothness across network (PUN) 0 Answers
[PUN2] Problem at pushing the other players 1 Answer
The player who leaves second is not being able to create or join room - Unity Photon Network 2 Answers