Illegal view ID:0 method: SpawnWithPhotonViewRPC GO:Players

Options

I'm getting the above error from a PhotonView component on the root game object of a prefab, which is simply placed in a scene. While the Editor is not playing, everything looks fine and the PhotonView component has a valid ID (e.g. 18). However, as soon as you hit "Play" in the Editor, the prefab seems to be reinstantiated and the view ID is reset to 0.

Is there any other solution to this, rather than unpacking the prefab in the scene?

Thanks in advance

Rene

Answers

  • Tobias
    Options

    There is an editor script that should be assigning ViewIDs to PhotonViews in the scene, while keeping the viewID as 0 for prefabs. This had some fights with Unity but there haven't been reports of this issue in a while.

    You could try setting a viewID on the prefab and or the scene object. Save scene and project. I guess the prefab's view has a 0 as viewID?

    Which PUN 2 version do you use and which Unity Editor?

  • rneumann
    Options

    Hey Tobias - thanks for the answer.

    I'm using PUN2 2.40 and Unity 2020.3.23f1.

    In the spirit of Unity's Prefab system, the viewID should be an override to the Prefab value in the scene, right? However, it isn't listed as an override... the only solution I found to make this reliably working is to unpack the prefab in the scene - it just looks like the viewID allocation only really works on gameobjects native to the scene.

    When you say "There is an editor script that should be assigning ViewIDs to PhotonViews in the scene" - I noticed some Exceptions on PhotonView editor scripts. or example the one I mentioned in this post:

    Could that also be a reason??

  • Tobias
    Options

    That may be related, yes. It's part of the code that would assign ViewIDs.

    I would expect the LTS version to not have such bugs. You could try 2020.3.25 maybe.

    Alternatively, create a minimal project with the prefab / GO setup you now use. Check if that reproduces the issue and if it does, you could send us a download link for Dropbox or alike to: developer@photonengine.com

  • rneumann
    Options

    Unfortunately - as it seems - the issue ain't reproducible in a minimal project. Dor a moment, I thought it could also be realted to the order of scripts at the prefabs root - like: the PhotonView is not the top most. But also with that I was unable to recreate the same behavior in an empty project. Even more weird: I removed and re-added the PhtonView to the prefab in my main project a few times and now it seems to work there, too...

    I don't know...

    Thanks for your assistance and I'll keep digging... ;)

  • Tobias
    Options

    Hm. This kind of inconsistent behavior happened before in Unity. Somehow, removing and adding the components back into the prefab can have some effect on the results (which is not great). I didn't want to make this suggestion as it sounds like I'm grabbing for straws. :)