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.

SetActive(false) object for all players in room

2022-04-28 07:43:56


I have a prefab "A", when i touch him i first instantiate it (the prefab has photon-view and Photon-Rigidbody-View.

Instantiation part:

GameObject "B" =  PhotonNetwork.Instantiate(A, new Vector3(0, 0, 0), Quaternion.Euler(new Vector3(0, 0, 0))).

The problem is when i am trying to SetActive object "B".

For me the object is disabled but for everybody else it is not.

How can I set active an object for all players in room including I ?


2022-04-28 13:00:10

Everyone else is not running this exact code. They instantiate the object because they received a message to do so (to replicate what the one client did). Calling SetActive(false) is not synchronized (not even on a networked object).

There is a IPunInstantiateMagicCallback interface, which you can implement and put that script on the prefab. Whatever you want to do to it initially, do it in there and all the instances will run this code.

Again, keep in mind that only one client / player is actually controlling the object.

2022-04-28 14:48:43

But after creating "B" from "A" using thePhotonNetwork.Instantiate(.....) I want to change "B" scale / Material.

  1. I tried changing the scaling with *[PunRPC] RpcTarget.AllBufferedViaServer....*for all users including me.

  2. When i do try to scale it, It is is making a "new B" in the new Scale I wanted but also keeping the Original "B" with his original scale. (and i wanted to change the originial "B" scale)

My code:

2022-04-29 13:38:23

Define the new scale and material before you PN.Instantiate. Pass both values as instantiation data (the last, optional parameter of PN.Instantiate). This data is then available in IPunInstantiateMagicCallback which will run on all instances (local and remote).

The docs should have some more info.

2022-05-02 14:32:14

Thank you but unfortunately it did not work as I expected.

The custom data is working (scale, rotation, position & parentName)

In "OnPhotonInstantiate" function I firstlook for the parentName in the scene and then set it as parent for the new object, just after that I am using the custom data.

The weird thing is that after instantiation the new obj I see him on the OtherPlayer hand and not on mine as expected.

2022-05-03 14:43:11

If the parent has a PhotonView, you could refer to this view's viewID instead of using a name. Names are not synced, so .. I can imagine you find the wrong one.

2022-06-15 07:01:20

Even after I found the parent by his view ID (Thank you for the great idea) when the object attached the just OTHERS players can see the obj and not the creator...

2022-06-15 11:28:29

Can you describe the current state some more? I don't see how only the creator of an object should not see it...

2022-06-17 11:07:45

I am building a VR multiplayer game with the oculus package.

My goal is that all players in the room will be expose to an Object called "Gun 77".


Prefab "Gun 77" has the following components:

  • Sphere Collider


  • [ → Ownership set to “TakeOver”]


  • [collision detection: Discrete, 2 checkboxes approve (use gravity, is kinematic)]


  • [All 3 checkboxes approve (teleport, sync velocity, sync angular velocity)]

  • XR Grab Interactable


When I first grab Gun 77I want to:

  • Instantiate a the same prefab from resources (Gun 77)

  • Put him as a child of my player left hand (left hand has a photonView, PhotonAnimatorView)

  • Change his scale

  • I want the new gun I created will be exposed to everyone in the scene including me of course.

Instantiation process:

I am using PhotonNetwork.Instantiation(...) and adding Custom Data

  • to it such as (parent PhotonViewID and scale size)

I have a AssetCreatorwho is responsible for the creation of new guns with MonoBehaviourPunCallbacksand OnPhotonInstantiatd

  • for getting the custom data.


  • don't have on him any photon view components attached.


Uploaded 2022-06-17T11:23:24+00:00 130284 bytes The Problem:

  • The Client who trigger the event in AssetCreator for creating the prefab ( Gun 77 ) sees it at the correct size (after I changed it during instantiation), but others see it at the default size.

  • Gun 77 (attached to the creator's left hand) moves smoothly, while others see it jumping between frames

  • The problem occurs whether I am the master client or a regular client

Back to top