[Possible bug] Duplicate ViewID:s

Hi there!

My levels are built up of platforms (scene objects) that have PhotonViews (since they need to be removed over the network at runtime). Since they are "spawned" by the scene, they are sceneViews and get unique viewID:s assigned, which can be seen in the editor. However, I ran into serious problems with these ID:s getting mixed up, resulting in RPCs being sent to the wrong platforms. I could confirm this by Update{Debug.Logging} the photonView.id in the platform script. Even though in the editor I could see that the id:s should be different, the platforms posted "id:2" id:2" id:2" id:2" . (instead of 1, 2 ,3 ,4, 1, 2, 3, 4... as expected).

What I eventually realized was that if you drag your prefabs into the scene, one by one, things work just fine. However, if you use the ctrl+d (duplicate) to create a new instance of your prefab in the editor, the viewID on your new instance will be the same as the one you copied. Not in the editor inspector though (which makes it hard to realise this at first), but when you run the game (even when running in editor). Ctrl+d:ing your level objects can be pretty important for level designers.

Can you reproduce this? Is it a bug? Working as intended? ...or just me screwing something up? :)

EDIT: When this happens, the warning "PhotonView: Wrong ID(2) on Block_Dest_4_2, checking entire solution for fixes" is logged.

Comments

  • Does this involve disabled gameobjects (or even disabled PhotonViews)?
    I did test and fix duplication of gameobjects, but looks like I might need to give this another look.
  • I'm not sure if it has anything to do with disabled views or objects. In my current project none of the PhotonViews or GameObjects are disabled from start or even get disabled when running, so it's not something I have thought about.

    Nice to hear that you are working on it! Looking forward for the update.
  • Just wondering how things are going with this. Any idea of when a patch will be available letting us duplicate objects with photonViews in the editor? I know things take time (and I'm not a paying customer yet), so no worries, I'm just curious. ;)
  • Could you please replace PhotonEditor.cs with the following code:
    http://pastebin.com/Jj0Pd36w
    
    I have indeed found and fixed a bug for duplication of scene photonviews, please let me know if this fixes all your issues.
  • Thanks for your reply. I'm afraid it didn't help much though. The copies still gets the "original's" viewID when I click run. Or do I need to do something in addition to replacing all code in PhotonEditor.cs with the one from pastebin? (I did that, and restarted Unity, nothing more). It's not impossible that I'm doing something wrong on my side.

    I made a picture that I hope can clarify the issue (hi res, 5mb). I'd be happy to share my project with you as well if you cannot reproduce it and you think that'd help.

    http://dl.dropbox.com/u/3417942/viewIDduplicateBug.png
  • I think that with this latest code this problem won't return for new duplciations anymore. So I think the cause is fixed, most likely you can fix this by removing the old PhotonView and re-adding it.

    However, I am curious why the viewID is being reassigned at runtime, I have no idea how this would happen. So if you have no problem sharing this project I'd like to take a look indeed (you can PM me a link)
  • I thought about that. So I actually tried putting a completely new object in, then copy that one. Unfortunately, same results. Have not tried starting on a new scene yet though. I'll make a zip for you and pm the url. And please let me know if I can be of any assistance.
  • You are using a old version of PUN. To fix this, please update to the latest version from the asset store(1.14.2 atm). After doing so you'll have to fix one compile error by referencing your prefab by name in the PhotonNetwork.Instantiate (you could use prefab.name).
    With the latest version you might only have to re-add the photonview to permanently fix the bug.
  • It works great now, Leepo. Sorry for having missed the update. Thank you very much for your support! I really appreciate it.
Sign In or Register to comment.