Quick Question about PhotonViews

Options
I looked in the documentation and couldn't find it at all. I've recently just had this problem, but objects in game with Photonviews that have ID's that might match a gameobject entering with a similar Photonview destroy the entering object.

For example, if I have a ball item with a Photonview ID of 8 on it, and a player joins whose Photonview ID also happens to be 8, the player is destroyed.

How can I prevent this happening without being careful to change the Photonview ID's every time? Just in case something else gets instantiated in the room with a similar ID ( Like when Instantiating an item with a PhotonView already on it ). Is there a way to force the insignificant objects to just pick a different ID?

Comments

  • Tobias
    Options
    If you use PhotonNetwork.AllocateViewID(), the viewIDs won't clash.
    To make this work we assign a range of values per player. Player ID 1 has range 1000 to 1999.

    PhotonNetwork.Instantiate() uses this internally, too.


    If you don't want to use this system, you have to come up with some scheme to avoid clashes yourself. Sorry.

  • Tobias
    Options
    And to avoid clashes of IDs when users loaded different scenes:
    Use the PunSceneSettingsFile. Per scene (name) you can define which is the lowest viewID that's automatically assigned.
    In best case, all users load the same scene, though.
  • kittyLLLL
    Options
    Awesome! Thank you so much, Tobias.