PSA: If you add Network Identity to your game object, your game object will be inactive upon start

Network Identity is a component added to a game object for use with networking.

I learned this after 1 hour CTRL+F my entire code trying to find out why a simple “MonoBehaviour” to “NetworkBehaviour” made my game object inactive at the start of the game.

That’s all.

Is this a bug or something?

I don’t know.

Are you using Unity 5.1.2? I’ve found that Unity 5.1.1 is not functional with lots of networking stuff.

It’s because objects that start in the scene with a NetworkIdentity are considered “scene objects.” They are disabled so that the Server can spawn them, causing them to become active (and therefore synchronized) on all clients simultaneously.

By default the server’s NetworkManager spawns all scene objects when it’s ready. However, if you’ve extended the manager, it’s possible to accidentally override this spawning and have to do it yourself. This is easy: NetworkServer.SpawnObjects().

This is desired behavior. The point is network stuff should not be active until an actual network game is created.

2 Likes

Yes.

1 Like