Problem with view ids

Options
Hello,

I've imported Photon to my game hoping to make it multiplayer, but I have a problem.
Unity gives me constantly warnings of Had to lookup view that wasn't in dict: View (0)1003 on GameObject.

What I do is having a scene with 4 units all of them having PhotonView components and another static object with PhotonView which dispatches RPC and handles them. When a user logs in the MasterClient dispatches to all players the new user's photon id and updates the Owner of PhotonViews of the units he controls (plus the new user also receives the player ids of previous players and changes the Owner of all units). That works, but I constantly get the above warnings.

Any ideas?

Comments

  • vadim
    Options
    Hi,

    How do you update owners? Even this is possible somehow, looks like switching owners is not supported well in PUN currently.
    Why do you need that?
  • Uhm, ownerId is public in PhotonView and that's what I wanted to change. The owner of a PhotonView. It seemed logical to me. And it works if you exclude the warning.

    I have some pre-existing units in a level, and when a player joins a room the MasterClient assigns them the units they are responsible for by changing the ownerId . I hope I didn't mess with the Networking Gods :oops:
  • vadim
    Options
    Changing ownerId directly is not good idea despite it's public.
    Absence of documentation on that property makes me think that it's public for internal usage or by mistake.

    What is purpose of changing owner of units? I guess initially they are Scene Objects (made with PhotonNetwork.InstantiateSceneObject) and belong to master client. Can you leave them master's after joining player but control them by that player?
    I can't remember anything special about ownership besides automatic object destroy after owner left.
  • vadim wrote:
    Can you leave them master's after joining player but control them by that player?

    I believe I can, although it would need a lot of tweaking. But is there a reason for this? Why that warning about the viewIds is so important, since it works?
  • vadim
    Options
    I did not say that this warning is important.
    General rule is that you can safely skip warnings.

    But looking deeper into the issue I found some undocumented feature usage that may cause potential problem. Just warned you again.
    How do you know that this is not the reason for the next bug you will face in your app even now everything looks working fine?
  • I don't, that's why I ask, and thanks for the warning :) Although I should ask you to better document the code to avoid users like me asking these kind of questions :oops:
    Also I don't use any instantiation like the PhotonNetwork.InstantiateSceneObject you mentioned. The units just exist in the scene and the PhotonViewer belongs to the scene too. How could I make it so that the owner is the MC? Or is it that PhotonViewers with Scene owner always belong to MC?

    Thanks for the help so far!
  • vadim
    Options
    To make use of PhotonView attached to object, you must create object with PhotonNetwork.Instantiate(). Instances will be created automatically on all clients and creator's player id will be assigned as ownerId. After creator leaves, all object instances are destroyed automatically.
    With PhotonNetwork.InstantiateSceneObject(), current master client assigned as owner and in case master leaves, next master reassigned as owner automatically instead of destroying instances.
  • Thanks. I believe I can put that to good use.

    Thanks for the help :)