The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Photon ViewId

2013-12-14 16:26:55


I'm new to Photon and currently working to integrate Photon engine into my game. I've created a small demo to understand how Photon work and it's working fine. Then I tried to integrate Photon into my game and tried to make it work with the demo. But there are some problems. First, it seems photon want to make sure both side use the same scene so I have to disable those line of code. Then I got the "Illegal View Id: 0..." error on my game side even though the 0 should be allowed. If I tried to set the viewId on both side to a same number but on the demo I cannot set it to 0 so I have to set to something else and on my game the viewId keep switching back to 0 no matter what value I set it to and I get the error "Illegal View Id: 0..." again and again.

Could someone tell me why PhotonView need the Id? Does both side have to have the same ViewId when calling and receiving RPC Call? Why is the view Id keep changing to 0?

Sorry for my English.


2013-12-16 11:42:34

Who says viewID 0 should be allowed? ;) PUN doesn't allow it. Use 1 or up. ViewIDs identify a PhotonView on a specific GameObject instance. It's more or less synonymous with: "that object".

For objects in a scene, you can set the viewID. The have to be unique though, so if you set 1, 2, 4 and then 1 again, all will be re-assigned automatically and IDs might change more or less in random ways. ViewIDs of Prefabs are set at runtime. Before it runs, we don't know how many GameObjects you instantiate in which order.

2014-01-10 18:53:24

I have some scene-owned photon views, with the View ID configured to set at runtime, but when I load the scene in-game (by triggering a level load from another scene) the photon view IDs get set to 0.

Interestingly enough, this happens only for this one prefab but not for other scene-owned prefabs.

Also if I load this scene directly (having it active and then hitting play), the view IDs all get set correctly.

Any suggestions on what I should look into?

2014-01-10 19:48:16

I found a fix for this - although not sure exactly why it works.

I had added the PhotonView component to the prefab after I had already placed this prefab throughout each scene. I hit 'revert' on one of these prefabs in each scene, and it seemed to trigger a recalculation of each photon view ID in the scene. The next time I dynamically loaded the level, each of these photon views now had a correct view ID.

2014-01-14 10:21:11

Maybe the Editor scripts ran into some problem and couldn't set the viewID in the instances in the scene or so. When you corrected the PVs, you most likely triggered the viewID assignment and saved the scene, too. This fixed the issue. Sorry for the inconvenience.

2014-05-11 23:19:12

I ran into this bug again, and I think I have a pretty good reproduction case and workaround.


  • Create a prefab without a PhotonView.
  • Place instances of this prefab in various scenes.
  • Add a PhotonView component directly to the prefab.
  • Run the game and load the scene dynamically - all the prefab instances will have Photon View IDs of 0.


  • In the editor, load each scene.
  • Save the scene.
  • Run the game and load the scenes dynamically - the Photon Views of the prefab instance will be correctly assigned View IDs > 0.

Basically, the instances with photon views need to be updated once within the editor, just by loading the scene in the editor, and then they will work correctly at runtime.

2014-05-12 11:09:47

Hm, yes, that's a problem. When you describe it like this, then it's actually a known issue. We have to update the scene instances of a prefab to assign a viewID in that level. We can only do that when you open a scene and save it once it's "fixed". I am not sure if we could get around opening the scenes. We would have to make sure that an object gets the same viewID on all clients, no matter how it loads the scene.

I could add an update method which automatically loads all scenes to update them. And of course I can make this requirement more visible / better known for everyone.

Back to top