Search Unity

UNET move sync

Discussion in 'UNet' started by KoSaJ, Oct 30, 2015.

  1. KoSaJ

    KoSaJ

    Joined:
    Oct 30, 2015
    Posts:
    2
    Hey,
    can some one help me understand how should I synchronise the players positions? After couple of fails on my own I tried to follow the first tutorial of @GTGD + added SebLague player scripts to test the player position sync and this is still not smooth for me I see the player is still lagging out even with lerp attached or without it.
    Is it common or im just doing something wrong?

    test project:
    https://bitbucket.org/KoSaJ/network...4feec4b2009/2d network test/Assets/?at=master
     
    slimmedaan likes this.
  2. teremy

    teremy

    Joined:
    May 2, 2015
    Posts:
    88
    If you attach your project, you should at least name the classes, that are relevant to your problem ( where you are currently syncing the position ). People probably don't want to spend too much time reading through all your code.

    Also you could give a link to the tutorial, that you were using.

    How you should synchronise is up to you, personally I prefer NetworkMessages, but I see people often use sync vars or network transforms.

    Looks like you are syncing using Command/ClientCallback and a syncvar. What do you even by lagging? Is it the local player that's lagging ( 0 ping ) or other clients that are connected?

    Another thing is, I would not mix view and logic. Interpolation should only be visual, but not actually change a player's position ( for now you can probably ignore this, but I'd rather have another gameobject for the player's visual representation that lerps its position to the players position, so the player object always has the correct position and not a lerped one ).
     
  3. KoSaJ

    KoSaJ

    Joined:
    Oct 30, 2015
    Posts:
    2
    so this is the class for player sync https://goo.gl/OmlLcW (used the goo because the link was on 3lines)

    GTGD tutorial


    for me both are lagging hope you will see it on this short video


    what do you mean by mixing view and logic?
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yeah that's pretty normal. It's probably not sending out packets at the same rate as update. Games online have far greater differences, you just don't get to see those.