Illegal view ID

Options
Hi,
I have a problem with illegal viewID on a PhotonView.

Works:
//instantiate, there's no "networking" code on the instance
GameObject newPlayer = PhotonNetwork.Instantiate(playerPrefab.name, pos, rot, 0);

print(newPlayer.GetComponent<PhotonView>().viewID);
//prints 1

//send RPC
newPlayer.GetComponent<PhotonView>().RPC("SetUpPlayer", PhotonTargets.All, parameter);

//RPC received

newPlayer has viewID of 1, everything works.

However what doesn't work:
//instantiate, however this time there's instantiation of a networked object in the instance, see the code in the other table
GameObject newPlayer = PhotonNetwork.Instantiate(playerPrefab.name, pos, rot, 0);

//now I have both newPlayer instance and the child instance

print(newPlayer.GetComponent<PhotonView>().viewID);
//prints 0
// why?

//send RPC
newPlayer.GetComponent<PhotonView>().RPC("SetUpPlayer", PhotonTargets.All, parameter);

//RPC fails due to illegal ID
void Awake() 
{
        // the child is successfully created with proper view ID
        GameObject child = PhotonNetwork.Instantiate(otherPrefab.name, pos, rot, 0);
}

newPlayer has illegal viewID of 0, child has a correct viewID of [1] 1001.

Why does have the newPlayer instance viewID of 0?

Funny enough, I'm not sure if is it by any means connected but if I debug the viewID in Update loop things become a bit weird.
The viewID is 0 until I click on the newPlayer's instance in the inspector and then suddenly the photonView has ID of 1 in the inspector as well as in the Update loop. It looks like clicking on the object reassigns the ID or something.

I'm using Photon Cloud, PUN 1.15 and Unity 3.5.2f2.

Thanks,
makaka

Comments

  • Tobias
    Options
    The inspector assigns views for scene objects (in the scene, as opposed to instantiated while running ones).
    It should not do this for instantiated game views.
    You post the same code 2 times but it behaves differently. What do you do differently? I don't know what you mean by "there's no "networking" code on the instance". There is: PhotonNetwork.Instantiate...

    As for being online or not: Check PhotonNetwork.connectionState or how about updating a label with: PhotonNetwork.connected?
  • makaka
    Options
    Tobias wrote:
    The inspector assigns views for scene objects (in the scene, as opposed to instantiated while running ones).
    It should not do this for instantiated game views.

    Yeah but it does happen, I will check again tomorrow.
    Tobias wrote:
    You post the same code 2 times but it behaves differently. What do you do differently? I don't know what you mean by "there's no "networking" code on the instance". There is: PhotonNetwork.Instantiate...

    1st example: Parent instantiates Child
    2nd example: Parent instantiates Child which instantiates another Child by calling PhotonNetwork.Instantiate in its Awake() method

    Yes, the actual code of the parent is the same BUT what is different is that in the second example I'm instantiating a new object in Awake() of the instantiated object.
    This causes the PUN to assign an illegal ID, works perfect in the first example, fails in the second.
    Tobias wrote:
    As for being online or not: Check PhotonNetwork.connectionState or how about updating a label with: PhotonNetwork.connected
    I don't think I had any question related to this :].

    Thank you for your help, appreciated.

    makaka
  • Tobias
    Options
    We made a minor fix to the inspector yesterday: When the owner of an instantiated photonview wasn't available anymore, it could change the view ID.
    Is that your usecase?
    Yes, the actual code of the parent is the same BUT what is different is that in the second example I'm instantiating a new object in Awake() of the instantiated object.
    This causes the PUN to assign an illegal ID, works perfect in the first example, fails in the second.
    Ok, we can take a look at that.
    I don't think I had any question related to this :]
    Huh. Wrong thread?! :)
  • makaka
    Options
    Alright, I made a simple test scene to check if the error occurs and it does. I might be doing something wrong so let me know if that is the case:

    Here's the video and comments on it (watch in HD):
    https://vimeo.com/44794159

    00:08 - I'm using the Enable script from PUN
    00:16 - There's a simple game manager, the Child GO is in Resources
    00:21 - The child has a photon view and the child script with ChildOfChild GO that is in resources
    00:30 - The ChildOfChild has a photon view
    -- NOW I'm showing the scripts - hopefully self explanatory --
    01:30 - Starting the game
    01:34 - Illegal view 0 problem
    01:42 - ChildOfChild photonview id is reported correctly
    01:47 - Child photonview id is reported correctly
    -- NOW I'm uncommenting the Update that prints out the photon view ID every frame --
    02:33 - ID is reported as 0
    02:47 - the moment I click on the GO in the inspector, the ID is reported as 1

    What do you think? Am I doing something wrong?

    Thanks,
    makaka
  • makaka
    Options
    Also, I can't seem to find the new update. The version on the Unity's Asset Store from the 14th of June.
    Thanks
  • Tobias
    Options
    I didn't submit the update yet. We're looking into some other things, too, so it might take another few days.
  • makaka
    Options
    Tobias wrote:
    I didn't submit the update yet. We're looking into some other things, too, so it might take another few days.

    Did you see my previous post, the one with the video? Thanks for checking it out, makaka
  • Tobias
    Options
    Pls. simply send me your project: developer@exitgames.com or attach it here. Export from Unity and you're fine.
  • makaka
    Options
    I'm very confused now as the code now works. I reverted to the very first version of the test scene on the asset server and it runs without any issues. How is it possible that there are inconsistent results? I would understand if there was a change in the code but even if I revert to the version from the video, results are now different. I'm using the cloud version on trial, my ID hasn't changed, PUN hasn't been updated, code is the same, yet now the code works while it didn't for days / a week before.

    I'm send you the example in the attachment but now it magically works...
    EDIT: nope, can't add attachment, maybe there's a size limit (it's 11MB) or it doesn't support Opera. I'll send it by mail
  • Tobias
    Options
    I got your mail and the download. Thanks.
    Will take a look on Monday. It just didn't fit in today and you seem to have it fixed.

    Maybe some weird setup happened during your initial creation of the scene and then prevented a correction?
    If you find a possible cause, let us know.