Search Unity

UNET FPS Fast Paced Authoritative character controller

Discussion in 'UNet' started by lucasmontec, Feb 6, 2016.

  1. lucasmontec

    lucasmontec

    Joined:
    Apr 7, 2015
    Posts:
    97
    Hi guys! I have posted this before but now I kinda need help. Like, I'm tearing my hair off!
    I'm coding an Authoritative Character Controller that uses the unity standart assets FPS character controller as a base. Also we (we are a team actually) are using the character controller for movement, not a rigid body nor a collider.
    I have read GenaSG's one. Its different from what I'm trying to achieve. I need strafing, smooth kinematic movement with low bandwidth usage. My current state is that for some evil reason in different machines the code is behaving differently! In my machine I have a tiny amount of reconciliation errors and server simulation, though in my team's machines the code produces much more errors. Some time produces less errors too.

    I'm really having trouble because of this. Every time I code some fix that reduces the amount of errors I'm having, the SAME code on my friend's PC produces MORE errors than before! I'm using a code that should be time-independent (unless I missed something). I spent many days trying to figure this out but now I guess I need help of fresh eyes...

    The code is MIT licensed, so if anyone helps me figuring this out, man you can use the hell out of my controller! The entire community can!

    There are a few things that I'm already up to:
    I'll optimize my serializer A LOT (I can bundle all booleans into a byte, I don't need to send rotation floats unless there is rotation, the same for movement vars).
    There is A LOT of debug code mixed in... I'm using almost all of that debug.
    Strafe isn't complete, the forward strafe factor is still to be coded.

    https://github.com/InVoid-Games/UnetCharacterController
     
    dnnkeeper likes this.
  2. lucasmontec

    lucasmontec

    Joined:
    Apr 7, 2015
    Posts:
    97
    :( I'm strill trying on this... Added a few tests but no idea so far.
     
  3. dnnkeeper

    dnnkeeper

    Joined:
    Jul 7, 2013
    Posts:
    84
    I see you use System.DateTime.UtcNow.Ticks as timestamps. Are you sure it is synced across network? Try using Network.Time instead.
     
  4. lucasmontec

    lucasmontec

    Joined:
    Apr 7, 2015
    Posts:
    97
    Shouldn't be a difference since I only use client time. The stamps just go across the server.
    I changed hahah to used Network.time. Just because... well. I had to test. Didn't changed much actually.
     
    Last edited: Feb 10, 2016
  5. lucasmontec

    lucasmontec

    Joined:
    Apr 7, 2015
    Posts:
    97
    I have decided a temporary fix. I'm going to send along with the inputs messages the client calculated position for each move. After each server move for those inputs, if the difference is small enough to the client terminal position, I'll set the server pos to the client's one. This should resolve inconsistencies with things like the character controller. This shouldn't be a final fix though, but I need this code working haha. Hacks shouldn't be able to affect this logic by changing the sent position since the server will validate each position per input.

    I have tested and in my machine this fix clears all errors. My friend again reported to still have errors on his.
     
    dnnkeeper likes this.