"Had to lookup view.." console warning when changing viewID

hi all!
I'm delighted by Photon Cloud. Quick and easy way to dive into
networking games dev. So, thank you Exit Games.

I'm having a unity project with 1st person controllers and vehicles the players
can control. Each client spawn its own 1st person controller and its
own vehicle. Each 1st person controller "stream" its position/rotation to all other clients.
Same for the vehicles. So far so good.
Players can "take control" of other players vehicles when empty. To allow that, the player taking control of someone else's vehicle, need to take owership of the GameObject he wants to control. To do so, i did the following:

1. allocate a new viewID and keep it in an integer var.
2. send by RPC the new viewID to Others so they change the viewID for that object.
3. change locally the viewID of the vehicle.

it works great, i become the owner of another player's vehicle when i step in.
and all version of the gameobject get updated with the new viewID.
One thing bothers me though, console gets filled up with a warning:

"Had to lookup view that wasn't in dict: View (0)2003 on vehicle"

NOTE: the warning occurs in my dev console when another player take ownership
of my empty vehicle by changing its viewID.

Is there a better way to proceed to that viewID change?
(to avoid these Lookup warnings)


  • anyone? any idea?
  • Hm. Where to begin?
    First, I'm happy you like the Photon Cloud and get along with it. Always cool to read nice comments :)
    I looked up the issue and it's caused by simply changing the viewIDs of existing PhotonViews.
    I think you could solve the issue by removing the old PhotonView from your object and by creating a new one, instead of applying a new ID.

    Some background:
    Changing ViewIDs is not working and I should better throw an error at that point.
    View IDs are expected to be immutable. They are cached internally for easy access without FindObjectsOfType(). A new PV registers (gets cached) when it gets an ID and never again.
    If you change the viewID several things break: The old ID stays in the cache but the new one never gets there. On lookup, the new viewID will be found (via expensive FindObjectsOfType) but is not entered into the cache. Doing that would add the same PhotonView into the cache with 2 different IDs.
    This step gives you the warning.

    Changing the viewID is tricky not only on the local level but when you used PhotonNetwork.Instantiate(), the ID also is used to reference this PhotonView on the server, which doesn't handle your RPCs.

    Please check what happens if you remove outdated PVs and add new ones?
    That should work.
  • Tobias thanks for the support! :D
    Very nice to have infos on how these viewID's work.

    So, as you suggested i went for a different approach (than messing with the viewID's)
    and remove then recreate PV's components on "network-instantiated" game objects.
    i proceeded like the following:

    When stepping into another player vehicle:

    1. Send an RPC to Others to call a method that:
    a. save the current ownerID
    b. destroy the PV component
    c. AddComponent a new PV
    d. wait a few
    e. new PV config is empty so: set the ownerID as it was previously
    f. new PV config is empty so: set the Observe to the right script (as it was previously)

    2. Locally do the same as point 1.

    All of this seemed ok until i noticed that when you add a PV programmatically,
    (using AddComponent) and setting the "Observe" property (also by script):
    the "Observe option" property is set to Off (by default)
    of course i tried to set that "Observe option" by script, but it's not there!
    (unlike observe or ownerID or viewID properties)

    When we manually drag-drop a script on "Observe"; "Observe option" is automatically
    set to "Unreliable." Which is what i need to do by script but unable to.

    Conclusion: im unable to set Observe Option to Unreliable by script (it is set as Off),
    so the master gameObject dont steam anything to the other versions of the object.

    Is there a way to set that "Observe option" property programmatically?
  • > Is there a way to set that "Observe option" property programmatically?
    That could be missing, right.
    In worst case, just add it. We provided the code of PUN so you could add stuff like that.
  • thanks Tobias,
    i might look into the sources to add that missing property.
    but for now i'll stick to my viewID's chaning code and live with these warnings filling the console.
  • I know this is an old post, but in case it's still helpful, the 'Observe option' flag is in the most recent PhotonView as

    public enum ViewSynchronization { Off, ReliableDeltaCompressed, Unreliable, UnreliableOnChange }
    public ViewSynchronization synchronization;

    Was a more elegant solution ever found for this issue? I see there are still numerous 'change of ownership' posts but haven't yet seen a clear resolution.
  • Change of ownership is not related to the ViewSynchronization setting.
    The owner is the client which will send the object's position (and other values) and ViewSynchronization defines how this data is sent: Reliable but compressed or unreliable.

    Ownership change is not easy to sync and not available "out of the box" right now.