Connected players move faster than host on their screens.

Options
Fourthedesign
edited July 2022 in Fusion

The player prefab has an empty with a standard Unity Character Controller, a Network Behaviour script attached, and a Network Transform component, with its interpolation target set to a "model" child transform.

The empty itself, is a child of another empty which holds the Network Object component and a Room Player component which holds data about the player.

This is a snippet from the Network Behaviour that controls movement:


public override void FixedUpdateNetwork()

   {

       if (GetInput(out NetworkInputData data))

       {

           CurrentInput = data;


           if (AffectedByGravity)

               UpdateGravity();

           if (CanMove)

               UpdateMove();

           if (CanRotate)

               UpdateLook();

           if (!LastInput.GetButton(NetworkInputData.E_Buttons.BUTTON_A) && CurrentInput.GetButton(NetworkInputData.E_Buttons.BUTTON_A))

               OnJump();


           LastInput = CurrentInput;

       }

 }


The three Update methods use the Character Controller's Move method to move the character.

When I host a game, and join through another editor instance, the host sees everything normally. Host moves normally and the player that joined also moves normally.

However, the joined player appears to move much faster on their screen, and as a result the two player screens fall out of sync.

I also found that the FixedUpdateNetwork method for their player instance gets called at more than twice the speed of the host. The host player on the other hand, appears to move normally without any problems and is synced on both screens.

Input-wise, everything seems alright and synced properly.

Best Answer

  • Fourthedesign
    Answer ✓
    Options

    SOLVED: Issue was that I was using Unity's default Character Controller and not photon's wrapper (NetworkCharacterControllerPrototype). After switch my move() calls to use the wrapper it worked fine.

Answers

  • Fourthedesign
    edited July 2022
    Options

    After debugging, I find that the InputAuthority for the joined player on their side changes between FixedUpdateNetwork calls, sometimes being the Host, and other times being the joined player. Both in equally distributed amounts (e.g 1000 calls where authority is host and 1000 calls where authority is themselves).

    It also seems like the joined player has input authority over the host player in some of these calls.

    Even if I replace everything inside the FixedUpdateNetwork method with just a CharacterController.Move() call, I find that the joined player moves much faster, as their version of the FixedUpdateNetwork method gets called more times than the version on the host's game.

  • Fourthedesign
    Answer ✓
    Options

    SOLVED: Issue was that I was using Unity's default Character Controller and not photon's wrapper (NetworkCharacterControllerPrototype). After switch my move() calls to use the wrapper it worked fine.