Search Unity

Question Spawned objects movement is laggy on all but masterclient

Discussion in 'Multiplayer' started by JD_FVTC, Apr 13, 2021.

  1. JD_FVTC

    JD_FVTC

    Joined:
    Oct 20, 2017
    Posts:
    54
    I have up to 16 spawned prefabs with just Text and a collider. On the master client the movement is smooth but on the other 3 players it laggy.
    The spawned objects rotate around the center of the scene via a script see below.
    They all have these components: Ridgidbody, photonview, photonTransformView, photonRigidBody view. See images for settings.

    https://ibb.co/rchjVTr
    https://ibb.co/YppB4hs

    What am I doing wrong? How can I smooth out the movement on the other 3 players?
    Code (csharp):
    1.  
    2.     void Update()
    3.     {
    4.        if (center != null) {
    5.             transform.RotateAround(center.transform.position, axis, angle);
    6.         }
    7.     }
    8. }
    9.  
     
  2. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    This is a pretty standard question with multiplayer. A large part of making a multiplayer games is dealing with (and hiding) network lag. If you have a photon view on the thing then you only want to move it on the owning client, not every client. Then ideally what you do is make something that hides the lag between the actual location of the photon view and the visible model. You can lerp for example, or even use OnPhotonSerializeView to customize the movement from the data stream. Unfortunately there is no "click this toggle" solution to this problem. There are of course assets you can buy to fix it for you.