I set up my Prefab with a NetworkView-Component. When I look at the Objects of the Prefab in the Unity-Editor, they all have a NetworkViewId and Type “Scene”, however when I start the Game the NetworkViewIDs of all Objects of that Prefab become 0 and the Type changes to ‘Allocated’. Naturally no State-Synchronisation or RPCs work. Nothing appears in the Console either.
Does anybody know what is happening here? I would like to be more detailed but I have no idea what is happening here. I have other Prefabs with a NetworkView, but everything is working fine with them. I don’t even know if this is a bug or if I am doing something wrong.
Wow, I just found the Solution for the Problem:
The Objects that I had that problem with were in the Scene, before I gave the Prefab a NetworkView-Component. So after I deleted the Objects and put new Instances of them in the Scene it worked for the new Instances.
Why that problem happened now and not before (as I had another Prefab where that worked fine), I do not know, but the important thing is I now know what to do if that happens again. Thanks to whydoidoit and bunny83 for trying to help.
The thing is that every object in the scene with the network view component attached to it has a view id of 0, which means the owner is the server. Any other id is the client.
But again, this is from what I experienced with the network and haven’t read it from anywhere. Allthou I have recently figured that out, it seems to work for what the problem ive had with my pick up system in the multiplayer game im making.
To set a view id owner, you can see the box spawn example at the docs: Unity - Scripting API: Network.AllocateViewID
From all ive researched though, view id 0 is always the server, and the others are always the clients(have not tested with negative ids as -1, -2, ect.)
Hope this was useful. Cheers
I have found if you have a prefab in multiple scenes, and you apply a new child object which holds a NetworkView to the prefab it will automatically receive the ID of 0 (Using Unity 5.1.2f).
I have found a simple solution to this to be to re-import the project which re-allocates objects with new NetworkView IDs. I have also tried re-importing individual scenes, but on occasion the issue has remained.