Search Unity

How to implement jump on authoritative server?

Discussion in 'Multiplayer' started by Harrier, May 20, 2018.

  1. Harrier

    Harrier

    Joined:
    May 11, 2015
    Posts:
    8
    Hello, i am out of ideas how to implement jumping on authoritative server.
    My client movement works in three phases:
    1 client prediction
    2 server simulation
    3 client reconciliation

    I'm using CharacterControler.Move to do that.
    Client send inputs to server and receive state with position and rotation.
    Server will simulate empty input (basically gravity) if inputs are delayed and client will not ACK this state.
    Client position is always set to state from server and non-ACK queue of predicted inputs is replayed.

    Everything works fine even outside LAN, so i tried to implement jump like this:

    Code (CSharp):
    1.  
    2. //MonoBehaviour method that gets movement vector for CharacterController.Move
    3. public Vector3 GetMovement(input, delta){
    4. int JumpStepMax = 10;
    5. int jumpStep = 0;
    6.  
    7. if (isGrounded && input.jump || !isGrounded && jumpStep > 0 && jumpStep < jumpStepMax){
    8. jumpStep++;
    9. //jump movement
    10. } else if (!isGrounded){
    11. //fall movement
    12. } else if (isGrounded){
    13. jumpStep = 0;
    14. //movement
    15. }
    16. return movement * delta;
    17. }
    But incrementing jumpStep does not work because of reconciliation phase.
    I am out of ideas, thanks for any help.
     
    Last edited: May 20, 2018