Search Unity

5.2.1p1 NetworkTransform rotation is wrong up to 90-180+ off

Discussion in 'Multiplayer' started by terravires, Sep 29, 2015.

  1. terravires

    terravires

    Joined:
    Mar 27, 2013
    Posts:
    103
    Does anyone know why NetworkTransform is unable to sync rotation on a rigidbody, via localhost with 4 total objects in the scene?

    I have only one script that moves two AI (host) objects:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Networking;
    3. using System.Collections;
    4.  
    5. public class FixedUpdateMove : NetworkBehaviour {
    6.  
    7.     Rigidbody _rigidbody;
    8.  
    9.     void Awake()
    10.     {
    11.         _rigidbody = GetComponent<Rigidbody>();
    12.     }
    13.  
    14.     void FixedUpdate()
    15.     {
    16.           CmdNetMove();
    17.     }
    18.  
    19.     [Command]
    20.     void CmdNetMove()
    21.     {
    22.         transform.Rotate(Vector3.up, 30f * Time.fixedDeltaTime);
    23.         _rigidbody.MovePosition(transform.forward * Time.fixedDeltaTime + _rigidbody.position);    
    24.         _rigidbody.rotation = transform.rotation;
    25.     }
    26. }
    27.  
    I have two AI objects in the scene, and then Network Identity and NetworkTransform on them. The prefabs are listed under NetworkManager under spawned objects. They appear on both host and client but rotations are way off. 90-180 or more. Position is close, but not very accurate considering there are only 4 total objects.

    Edit: moving the AI only (server side) code into a [Command] helped, but the rotation is still off and objects are not always in correct positions when joining.

    Any suggestions?
     
    Last edited: Sep 29, 2015
  2. bteitler

    bteitler

    Joined:
    May 11, 2014
    Posts:
    52
    I haven't been using NetworkTransform (wrote my own), because with a 5 second glance I could tell that it is very much a work in progress. It is possible you are doing something wrong, but I wouldn't assume so. The whole networking API seems like a work in progress to me, though the lower level API seems more stable. I would expect major bugs with this "feature".

    The first thing (out of many things) that concerned me was that NetworkTransform has the send rate capped to 30, which means you can never get better than 33ms latency (lame). I configured all my half life 1 mods to send updates at 100 updates a second... 13 years ago. I'm glad it looks like they are providing compression and various interpolation and snap settings, but it is clearly about 15% feature complete at best for supporting the majority of real use cases. The documentation is essentially non existent as well:
    http://docs.unity3d.com/Manual/class-NetworkTransform.html
    It is super important to know the exact details of what is going on or you will never be able to make the right precision and bandwidth trade offs for your game. I would expect that page to have like 15 pages of text for a complete feature.

    A real NetworkTransform feature in my opinion would provide many many different interpolation settings, compression settings, client side prediction settings, smoothing settings, quality of service settings, and massive documentation for all of these.
     
    PeterB likes this.
  3. terravires

    terravires

    Joined:
    Mar 27, 2013
    Posts:
    103
    Well I'm forced to use a rigidbody because without it NetworkTransform will not interpolate. Also, since the UNET way is to have the same scripts on server and client, using RPC/Commands appear to the only option.

    That helps with position, but rotation is just never fully correct for me. It's close, but seems to have issues.

    Then I'm getting a ton of problems with HLAPI CRC mismatch/out-of-sync errors. The errors seem wrong as a single scene it works. But when you use on-line/offline, it gives errors. Only thing that is carried across scenes is NetworkManager.

    I too got frustrated and started working on my own LLAPI/HLAPI middleware. Just a major pain to have to re-write and replace so much stuff. Also considering looking at forge, but not sure.