Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink

You are not connected. Please login or register

Unity Ninja Unity 3D Forum » HELP » Help (General) » Please can someone help me with this multiplayer (photon) issue?

Please can someone help me with this multiplayer (photon) issue?

View previous topic View next topic Go down  Message [Page 1 of 1]

zigglr


Member [Lv. 0]
Member [Lv. 0]
I have been trying to fix this for about a week, and i've asked on Unity answers but haven't had any help. For some reason, the other player has stuttering / laggy movement on my player's screen. Please could someone tell me how to fix it, I would appreciate it a lot. Here is the code to move the player (simplified):


Code:
  public Rigidbody2D rb2D;
 
        void Update () {
        Vector3 targetPos = new Vector3(369.1f, -188.9f, -0.1f);

        rb2D.transform.position = Vector3.Lerp(rb2D.transform.position, targetPos, Time.deltaTime * 0.06f);

    }




And the code to view the other player:

Code:

public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            //We own this player: send the others our data
            stream.SendNext(rb2D.transform.position);
            stream.SendNext(rb2D.transform.rotation);
        }
        else
        {
            //Recieve other player
            realPosition = (Vector3)stream.ReceiveNext();
            

        }
    }



I have a photon view and the player is a Rigidbody2D

Thanks a lot!

View user profile

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum