Fusion needs input validation
I want to put networking into the game I'm making and I figured I'd give Fusion a try. What I've found is that it's not ready for prime time because I'm getting null reference exceptions from the Fusion codebase and I should never get a NRE from closed source code. A lot more input validation needs to be put into the engine with useful error messages because these NREs are just useless to me and I have no way to figure out what's going wrong.
The first problem I encountered I pretty quickly figured out on my own, which was that due to script order my NetworkRunner wasn't getting initialized before something else tried to spawn a NetworkObject, but the exception I got was a rather useless NRE:
NullReferenceException: Object reference not set to an instance of an object
Fusion.NetworkRunner.Spawn (Fusion.NetworkObject prefab, System.Nullable`1[T] position, System.Nullable`1[T] rotation, System.Nullable`1[T] inputAuthority, Fusion.NetworkRunner+OnBeforeSpawned onBeforeSpawned, System.Nullable`1[T] predictionKey, System.Boolean syncPhysics) (at Fusion/Fusion.Runtime/Runner/NetworkRunner.cs:1687)
Fusion.NetworkRunner.Spawn (UnityEngine.GameObject prefab, System.Nullable`1[T] position, System.Nullable`1[T] rotation, System.Nullable`1[T] inputAuthority, Fusion.NetworkRunner+OnBeforeSpawned onBeforeSpawned, System.Nullable`1[T] predictionKey, System.Boolean syncPhysics) (at Fusion/Fusion.Runtime/Runner/NetworkRunner.cs:1642)
And now I'm facing this one:
NullReferenceException: Object reference not set to an instance of an object
Fusion.NetworkRigidbody2D.SetIsKinematic (System.Boolean value) (at Fusion/Fusion.Runtime/Components/TransformBehaviours/NetworkRigidbody2D.Logic.cs:16)
Fusion.NetworkRigidbodyBase.Fusion.IStateAuthorityChanged.StateAuthorityChanged () (at Fusion/Fusion.Runtime/Components/TransformBehaviours/NetworkRigidbodyBase.Logic.cs:136)
Fusion.NetworkRunner.Fusion.Simulation.ICallbacks.ObjectStateAuthorityChanged (Fusion.NetworkId id) (at Fusion/Fusion.Runtime/Runner/NetworkRunner.SimulationCallbacks.cs:61)
UnityEngine.Debug:LogException(Exception)
If Fusion is this hard to debug for the simple stuff then there's no way I trust it for anything more complicated: Read "My game"
Comments
-
Thanks for the feedback. We agree that more checks and better exceptions / logs are needed, no question.
A colleague will try to help with the second issue in a bit.
0 -
Hi @Supagoat ,
Can you give us more information?
- Which Fusion SDK build are you using?
- In which context do these errors happen?
- Do you have some reproduction steps to show this happening?
The second error happens if you are using
NetworkRigidbody2D
from a Game Object that does not contain aRigidbody2D
component on it. Is that the case?--
Ramon Melo
Photon Fusion Team
0