Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Third Party Are these the possibilities of Photon PUN 2

Discussion in 'Multiplayer' started by BigApp7e, Feb 2, 2021.

  1. BigApp7e

    BigApp7e

    Joined:
    Mar 10, 2019
    Posts:
    9
    Hello. I want to ask for your opinion.
    I have a project for a multiplayer game for mobile devices and I'm currently considering the possibilities for a socket server. I read comments about Photon PUN 2 and decided to check. My impressions are.
    Integration is really very easy but the end result I got is not good.
    In the syncheonization of movement there is an additional movement of the players. The movements end with some easing or movements are some jagy and weird. When jumping, things are also pretty bad. I guess these are Interpolation but still ...
    When debugging "ping" = between 70 - 110
    I also made a short video to show you what I mean



    My question to you is. Are these the capabilities of PUN 2 or is the error in my script?

    Does anyone have any idea where these extra movements come from and how they can be cleared up?

    My script is made as easy as possible for testing purposes.
    I have a class NetworkController: MonoBehaviorPunCallbacks

    after the standard connect, login and so on events and functions

    public override void OnJoinedRoom ()
    {
    player = PhotonNetwork.Instantiate ("player", new Vector3 (0, 0, 0), Quaternion.identity, 0);
    }
    In the Second Class PlayerPrefabScript

    private void FixedUpdate ()
    {
    if (!photonView.IsMine) return;
    rigidbody2d.velocity = new Vector2(x_direction * Time.fixedDeltaTime * moveSpeed, rigidbody2d.velocity.y);
    }

    In the Unity project I added Photon View to the prefab and in Observed Components -> PhotonRigidbody 2D View with a check for synchronize velosity.

    I will appreciate any feedback. Тhanks
     
  2. u-doug

    u-doug

    Joined:
    Jun 6, 2017
    Posts:
    11
    I'd suggest using the Simple addon library for PUN: https://github.com/emotitron/Simple_Addon_for_Pun2

    Import that into your project and add the Sync Transform component to your player, and it will nicely Sync whatever you tell it to in the inspector options.

    If you are looking to have collisions between the players you will still have issues, unfortunately that is a very difficult problem to solve made harder by everything in PUN being client sided.
     
  3. BigApp7e

    BigApp7e

    Joined:
    Mar 10, 2019
    Posts:
    9
    Thank you u-doug.
    With Simple addon library the animation has significantly improved. The extra movements almost disappeared but the problem with the delay remained. The ping reaches almost 150 from time to time. That's why I think the problem isn't just in the code. I will try other solutions and compare them to see which is better.
    Thank you again for your help
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,021
    The ping primarily depends on where you are and which region you connect to.
    In the editor it's easy to reset the "Best Region" value in the PhotonServerSettings. Give it a try.
     
  5. BigApp7e

    BigApp7e

    Joined:
    Mar 10, 2019
    Posts:
    9
    Thank you tobiass.
    I just try your advice. Unfortunately there is no changes. The Delay is significant.