Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Third Party Photon Server Delay in multiplayer

Discussion in 'Multiplayer' started by unity_012A831D0A89169FF54A, Mar 6, 2023.

  1. unity_012A831D0A89169FF54A

    unity_012A831D0A89169FF54A

    Joined:
    Oct 20, 2022
    Posts:
    3
    I am working on Carrom board game using Photon Server but when the Player One finishes his move and when the Player Twos moves comes it is taking Delay of about 10 seconds may be even more.
    I don't know whats going on here why it is taking this much of delay?

    Below code is for the game starting
    View attachment 1207759

    add Player Turn View attachment 1207762

    Round Begin
    View attachment 1207765
    Finished Turn View attachment 1207771


    NextPlayer Change turn
    View attachment 1207768

    HandleOwnerShip
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,056
    Attachments can't be found.
    A 10 sec delay is so much that Photon usually times out in this timespan. So .. something is odd.
    Are you sure you don't send everything in each frame?
     
  3. unity_012A831D0A89169FF54A

    unity_012A831D0A89169FF54A

    Joined:
    Oct 20, 2022
    Posts:
    3




    private float TURN_DELAY = 20f;
    private PunTurnManager turnManager;
    public float OPPONENT_WAITING_TIME = 1f;

    Add PlayerTurn Function:----------------
    private void AddTunrManager()
    {
    turnManager = base.gameObject.AddComponent<PunTurnManager>();
    turnManager.TurnManagerListener = this;
    TURN_DELAY = LevelManager.getInstance().turnTime;
    LogFeedback("Turn time " + TURN_DELAY);
    turnManager.TurnDuration = TURN_DELAY;
    }


    Round Begin Function:-----------------------
    public void RoundBegin()
    {
    strikedAnyPucks = false;
    isPlayerTurn = true;
    isPlayerStriked = false;
    timesup = false;
    strikerScript.MakeStrikerStrike();
    if (turnManager != null)
    {
    turnManager.BeginTurn();
    }
    }

    FinishedTurn Function:---------------
    public void FinishTurn()
    {
    isPlayerStriked = true;
    timesup = true;
    //WaitingForOpponent();
    HideWaitingMessage();
    }


    HandleOwnerShip Function:------------------
    private void HandleOwnerShip()
    {
    Player player = (playingPlayer != PhotonNetwork.MasterClient) ? PhotonNetwork.MasterClient : opponentPlayer;
    ChangeOwnerShip(player);
    playingPlayer = player;
    base.photonView.RPC("PlayerTurn", player, null);
    //base.photonView.RPC("UpdateLoader", RpcTarget.All, PhotonNetwork.LocalPlayer.ActorNumber);
    }


    BeginNewRound Function:-------
    private void NextPlayerTurn()
    {
    timesup = false;
    disableStrikerMover();
    strikedAnyPucks = false;
    isPlayerTurn = false;
    SynchPucks();
    strikerAnimator.photonView.RPC("MoveStrikerOut", RpcTarget.All, (!PhotonNetwork.IsMasterClient) ? restPositionTop.position : restPositionBottom.position);
    MoveStrikerHandlerToCenter();
    base.photonView.RPC("HandleOwnerShip", PhotonNetwork.MasterClient, null);
    base.photonView.RPC("UpdateLoader", RpcTarget.All, PhotonNetwork.LocalPlayer.ActorNumber);
    //hardik
    // Invoke("WaitingForOpponent", OPPONENT_WAITING_TIME);
    RoundComplete();
    }
     
  4. unity_012A831D0A89169FF54A

    unity_012A831D0A89169FF54A

    Joined:
    Oct 20, 2022
    Posts:
    3
    private float TURN_DELAY = 20f;
    private PunTurnManager turnManager;
    public float OPPONENT_WAITING_TIME = 1f;

    Add PlayerTurn Function:----------------
    private void AddTunrManager()
    {
    turnManager = base.gameObject.AddComponent<PunTurnManager>();
    turnManager.TurnManagerListener = this;
    TURN_DELAY = LevelManager.getInstance().turnTime;
    LogFeedback("Turn time " + TURN_DELAY);
    turnManager.TurnDuration = TURN_DELAY;
    }


    Round Begin Function:-----------------------
    public void RoundBegin()
    {
    strikedAnyPucks = false;
    isPlayerTurn = true;
    isPlayerStriked = false;
    timesup = false;
    strikerScript.MakeStrikerStrike();
    if (turnManager != null)
    {
    turnManager.BeginTurn();
    }
    }

    FinishedTurn Function:---------------
    public void FinishTurn()
    {
    isPlayerStriked = true;
    timesup = true;
    //WaitingForOpponent();
    HideWaitingMessage();
    }


    HandleOwnerShip Function:------------------
    private void HandleOwnerShip()
    {
    Player player = (playingPlayer != PhotonNetwork.MasterClient) ? PhotonNetwork.MasterClient : opponentPlayer;
    ChangeOwnerShip(player);
    playingPlayer = player;
    base.photonView.RPC("PlayerTurn", player, null);
    //base.photonView.RPC("UpdateLoader", RpcTarget.All, PhotonNetwork.LocalPlayer.ActorNumber);
    }


    BeginNewRound Function:-------
    private void NextPlayerTurn()
    {
    timesup = false;
    disableStrikerMover();
    strikedAnyPucks = false;
    isPlayerTurn = false;
    SynchPucks();
    strikerAnimator.photonView.RPC("MoveStrikerOut", RpcTarget.All, (!PhotonNetwork.IsMasterClient) ? restPositionTop.position : restPositionBottom.position);
    MoveStrikerHandlerToCenter();
    base.photonView.RPC("HandleOwnerShip", PhotonNetwork.MasterClient, null);
    base.photonView.RPC("UpdateLoader", RpcTarget.All, PhotonNetwork.LocalPlayer.ActorNumber);
    //hardik
    // Invoke("WaitingForOpponent", OPPONENT_WAITING_TIME);
    RoundComplete();
    }
     
  5. alaminkhalid

    alaminkhalid

    Joined:
    Feb 14, 2023
    Posts:
    1
    Did you solve this problem? If so, how did you figure it out, and what was the solution?