- Home /
Network Views from separate scenes causing conflicting IDs?
I have two scenes. Scene A, and Scene B.
When the game starts, Scene A is loaded. When the player connects to a server, Scene B is loaded.
Inside Scene A there is a NetworkView with a script containing DoNotDestroyOnLoad(). Inside Scene B there is another NetworkView (with nothing special about it).
The problem is, because both network views are in separate scenes, both of them have the same ID (zero), and consequently when they both eventually end up in the same scene together, they conflict!
Now, you might ask, why not have the NetworkView in Scene B just allocate a new ID at run time? Well, I was actually originally doing this, but I have come to the realization that runtime-allocated NetworkView IDs are one way -- IE, you cannot send RPCs to a NetworkView you do not own if its ID was allocated at run time. So, I started using scene-allocated IDs to allow for two way communication! But unfortunately, this has created the godforsaken ID confliction.
Note that invalidating the NetworkView from Scene A will not work -- I need BOTH networkviews to remain functional, and I need BOTH networkviews to support two-way communication.
Does anyone know a way for me to stop this ID confliction? Is there a way for me to allocate IDs at runtime, but still have them support two-way communication? An answer to either query will be marked as answer to this question!
Would this not work?
http://docs.unity3d.com/Documentation/ScriptReference/Network.AllocateViewID.html
If it does, let me know and I'll convert this to an answer.
Allocating a view ID seems to remove the ability for two-way communication :(
Hmm...bummer. Could you communicate that new view ID to the distant views through RPC? Honestly I've never attempted to use DoNotDestroyOnLoad with an object containing a NetworkView. That really sucks!
Well the interesting thing is, two NetworkViews on the same client have the same ID causing confliction -- I have found no ways of changing the ID of a NetworkView without Unity implementing its security layer and preventing users who do not own the NetworkView from sending RPC calls
Answer by Bunny83 · Feb 02, 2013 at 12:48 AM
That sounds like you need Network.SetLevelPrefix, right?
Both NetworkViews need to work for the game to run -- If I understand correctly, won't that cause the NetworkView from Scene A to stop working? If it doesn't, won't both NetworkViews still have the same ID + Prefix? Or am I mistaken about both?
Yeah this fixes it. I just checked my level loader and set my LevelPrefix to start at 1;
Your answer
Follow this Question
Related Questions
How to sync networkViewIDs 0 Answers
Network views wrong on re join to server 0 Answers
Overloading RPCs 1 Answer
Networking Error! 0 Answers