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.

Grab an object

2022-02-24 07:30:02

Hi !

I have object "X" in my scene. He has the following properties:


Photon Rigidbody View

XR Grab Network Interactable (I override the class by adding the following):

protected override void OnSelectEntered(XRBaseInteractor interactor)





So all works good but, When I want to duplicate (i mean-Instantiate) "X" and assign him to different object I have the following errors:

1.) PhotonView ID duplicate found: 1. New: View 1 on X(Clone) (scene) old: View 1 on X(scene). Maybe one wasn't destroyed on scene load?! Check for 'DontDestroyOnLoad'. Destroying old entry, adding new.

2.) InvalidOperationException: Duplicate key 1

ExitGames.Client.Photon.NonAllocDictionary`2[K,V].Add (K key, V val) (at <4c05f01c27d1415bafcda4c1ab7160e0>:0)


2022-02-24 13:40:08

Use PhotonNetwork.Instantiate() on a prefab, to get unique networked objects.

The duplicate key happens because you duplicate a networked object and thus assign the viewID. It can't be stored under the same ID twice, however.

2022-02-27 08:12:49

Thank you for your answer.

My problem is that I need object "X" will be a network object for others to see it or use it before/after me.

When I am using it I want to duplicate it.

If I cant do it, How can I have a reference/name of the object I just grab?

If I can get the network object name for example I can instantiate it directly from resources/online source without the error. (and not instantiate the original network object)

Am I right?

2022-02-28 10:58:28

The PhotonView.viewID is the reference. With it, you can find the related object. If it stores the name of it's prefab somewhere, you can instantiate that.

2022-02-28 12:17:01

Thank you !

Back to top