Search Unity

Networking smooth movement problem

Discussion in 'Multiplayer' started by dreyyy07, Dec 14, 2018.

  1. dreyyy07

    dreyyy07

    Joined:
    May 7, 2017
    Posts:
    8
    I'm developing a game using gamesparks for the multiplayer parts. I'm able to get updated positions but when I try to lerp to the new position, it has a jumpy effect. Here's a video of the effect:

    the blue player is me and the red player is an AI player, I've clicked on the AI player so that you can see how it's jumping around in the scene view. I just want to get smooth transition between packets before I work on the other sync issues
     
  2. dreyyy07

    dreyyy07

    Joined:
    May 7, 2017
    Posts:
    8
    Here's the code that handles the movement:
    Code (CSharp):
    1. transform.position = Vector3.Lerp(transform.position, goToPos, (Time.deltaTime/GameSparksManagerT.Instance.UpdateRate) * factor);
    2. transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(goToRot), (Time.deltaTime/GameSparksManagerT.Instance.UpdateRate) * factor);
     
  3. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,109
    I think you get new positions too seldom and your interpolation too fast for it.

    You can try one of this:
    - send new position more often
    - interpolate slower
    - extrapolate car on client side along the track and interpolate to positions that come from server
     
  4. dreyyy07

    dreyyy07

    Joined:
    May 7, 2017
    Posts:
    8
    Thanks for the reply, I tried all you suggestions but none of them really worked well

    -Sending positions more often just made the "jumping" happen more often
    -interpolating slower put the interpolated player and the client out of sync, position wise
    -extrapolating the car on the client made the car jerky for the client and didn't really make a difference on other side ..

    I think the reason why I'm getting this issue is because of how fast paced the game is.. might just stick to single player... I really don't want to, but I can't keep stalling the project. Do you have any more ideas?
     
  5. Whippets

    Whippets

    Joined:
    Feb 28, 2013
    Posts:
    1,775
    Joe-Censored likes this.