NetworkTransformPreview bug?

Is it just me or is unet just completely buggy and broken everywhere?? If you’ve been following my recent issues you’ll notice I’m having all sorts of trouble - I am new to unet so it could just be me however I have been writing software for 20+ years and this just seems nuts.

Anyway… I have a prefab that i’ve been using for a while now but deleted them all from my scene recently until today I thought I would add one back in and hit this error in the editor:

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Networking.NetworkTransformPreview.OnPreviewGUI (Rect r, UnityEngine.GUIStyle background) (at Unity-Technologies-networking-40b219054a68-v5.5/Editor/NetworkTransformPreview.cs:55)
UnityEditor.ObjectPreview.OnInteractivePreviewGUI (Rect r, UnityEngine.GUIStyle background) (at C:/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:113)
UnityEditor.ObjectPreview.DrawPreview (IPreviewable defaultPreview, Rect previewArea, UnityEngine.Object[] targets) (at C:/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:225)
UnityEditor.ObjectPreview.DrawPreview (Rect previewArea) (at C:/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:128)
UnityEditor.PreviewWindow.OnGUI () (at C:/buildslave/unity/build/Editor/Mono/Inspector/PreviewWindow.cs:98)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

Since I’ve been going through the unet code I thought I would take a look and this is the line in question:

float angleDiff3D = Quaternion.Angle(m_Transform.rigidbody3D.rotation, m_Transform.targetSyncRotation3D);

Just before it is the condition

if (m_Rigidbody3D != null) however this variable is never actually used, as you can see its using m_Transform.rigidbody3D instead. From an earlier bug(?) I found in the NetworkTransform there are cases were Awake() is not called and the NetworkTransform.rigidbody3D will return null in these cases as it is doing here.

m_Rigidbody3D and m_Rigidbody2D are never used anywhere in this code. The fix to the above problem is to consistently use either the m_Transform rigid bodies or the m_Rigidbody variables but not to mix them.

But back to the root cause, why is Awake not getting called on these NetworkTransform objects to being with?

This doesn’t address your specific issue, but I’ve noticed you’ve had several problems regarding UNET and scene objects specifically (as in gameobjects with network identities that are part of the scene rather than instantiated objects). Shortly after UNET came out I gave them a try, had issues with them syncing initial state on new clients, and quickly switched to instantiating everything. I’ve had very few problems since then.

(I’m also not using their relay servers or matchmaking system, so another common headache point avoided there as well)

Also, 5.6 has significant networking changes, bug fixes, and is set for release tomorrow supposedly. I wouldn’t go diving down the rabbit hole of UNET bugs this close to such a significant portion changing unless you’ve already verified these issues are still happening in the latest beta. YMMV

Thanks for the advice. As of yesterday I basically decided to dump all of the HLAPI stuff and write my own using NetworkServerSimple and NetworkClient with my own messages - so far this is working wonderfully for me and is really better suited since I do not want to use a server authoritative model. I was just hoping to avoid this since the supplied NetworkBehaviours are quite useful, but is a deep black pit when you hit a snag.