Syncing movement and rotation lag in complete scenes
Hello everyone,
I have a room that uses PUN 2, where two agents connect and wander around the scene. I am using the first person controller from Unity standard assets without a rigid body but a character controller. However, the problem is that when the agents connect in a complete room with assets and lighting the movement of the other client (the one we watch as players) has quite some lag. When I tried in a room with just a cube as ground everything works fine and no lag at all.
I have implemented lag compensation based on the documentation using the transform component. Here is the following code :
The settings from the PhotonService:
AppSettings:
AppIdRealtime: hidden
AppIdChat: hidden
AppIdVoice:
AppVersion: 1.0
UseNameServer: 1
FixedRegion:
Server:
Port: 0
Protocol: 0
EnableLobbyStatistics: 0
NetworkLogging: 1
StartInOfflineMode: 0
PunLogging: 2
EnableSupportLogger: 0
RunInBackground: 1
RpcList:
- DestroySpaceship
- Fire
- RespawnSpaceship
DisableAutoOpenWizard: 1
ShowSettings: 1
I have a room that uses PUN 2, where two agents connect and wander around the scene. I am using the first person controller from Unity standard assets without a rigid body but a character controller. However, the problem is that when the agents connect in a complete room with assets and lighting the movement of the other client (the one we watch as players) has quite some lag. When I tried in a room with just a cube as ground everything works fine and no lag at all.
I have implemented lag compensation based on the documentation using the transform component. Here is the following code :
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.IsWriting) { stream.SendNext(transform.position); stream.SendNext(transform.rotation); } else { networkPosition = (Vector3)stream.ReceiveNext(); networkRotation = (Quaternion)stream.ReceiveNext(); } }and the update function
void Update() { if (!photonView.IsMine) { transform.position = Vector3.Lerp(transform.position, networkPosition, Time.deltaTime * 5); transform.rotation = Quaternion.Lerp(transform.rotation, networkRotation, Time.deltaTime * 5); } }All this belongs to the script that is inserted as input to the PhotonView component. Last but not least, the profiler when running the scene shows an average of 70-80 fps so I guess its not the environment that creates the problem.
The settings from the PhotonService:
AppSettings:
AppIdRealtime: hidden
AppIdChat: hidden
AppIdVoice:
AppVersion: 1.0
UseNameServer: 1
FixedRegion:
Server:
Port: 0
Protocol: 0
EnableLobbyStatistics: 0
NetworkLogging: 1
StartInOfflineMode: 0
PunLogging: 2
EnableSupportLogger: 0
RunInBackground: 1
RpcList:
- DestroySpaceship
- Fire
- RespawnSpaceship
DisableAutoOpenWizard: 1
ShowSettings: 1
0
Comments
-
PUN is typically running with 10 updates/sec. Unless the game is below 10 frames, you should not notice this, especially, as you don't seem to send a lot of data per update.
I'm sorry but there is no simple explanation to this.0