diff --git a/MLAPI/MonoBehaviours/Core/NetworkedObject.cs b/MLAPI/MonoBehaviours/Core/NetworkedObject.cs index e488300..3805691 100644 --- a/MLAPI/MonoBehaviours/Core/NetworkedObject.cs +++ b/MLAPI/MonoBehaviours/Core/NetworkedObject.cs @@ -124,7 +124,8 @@ namespace MLAPI.MonoBehaviours.Core private void OnDestroy() { - SpawnManager.OnDestroyObject(NetworkId, false); + if (NetworkingManager.singleton != null) + SpawnManager.OnDestroyObject(NetworkId, false); } /// @@ -132,7 +133,8 @@ namespace MLAPI.MonoBehaviours.Core /// public void Spawn() { - SpawnManager.OnSpawnObject(this); + if (NetworkingManager.singleton != null) + SpawnManager.OnSpawnObject(this); } /// /// Spawns an object across the network with a given owner. Can only be called from server @@ -140,7 +142,8 @@ namespace MLAPI.MonoBehaviours.Core /// The clientId to own the object public void SpawnWithOwnership(int clientId) { - SpawnManager.OnSpawnObject(this, clientId); + if (NetworkingManager.singleton != null) + SpawnManager.OnSpawnObject(this, clientId); } /// /// Removes all ownership of an object from any client. Can only be called from server