Gameobject name is not synchronized over the network
Options
adrian17
✭
Hi,
I want to instantiate some objects over the network and change its name. I instantiate them but the name is not changed for clients. here is my code :
I want to instantiate some objects over the network and change its name. I instantiate them but the name is not changed for clients. here is my code :
[PunRPC] private void RPC_InstantiateObjects() { var bus = PhotonNetwork.Instantiate(Path.Combine("Network", "Magistrala"), new Vector3(-0.259f, 0.5971f, -2.167f), new Quaternion(0, 90, 90, 0), 0); RPC_tablet = PhotonNetwork.Instantiate(Path.Combine("Network", "TabletaDisplay"), new Vector3(-0.5f, 0.5902f, -2.167f), new Quaternion(0, 90, 90, 0), 0); int index = bus.gameObject.name.IndexOf("("); if (index > 0) bus.gameObject.name = bus.gameObject.name.Substring(0, index); int index2 = RPC_tablet.gameObject.name.IndexOf("("); if (index2 > 0) RPC_tablet.gameObject.name = RPC_tablet.gameObject.name.Substring(0, index2); RandomTablet(); }And here is where i call that method:
public override void OnJoinedRoom() { if (PhotonNetwork.IsMasterClient) { PV.RPC("RPC_InstantiateObjects", RpcTarget.All); } }Has anyone any idea why the name is not changed for clients ?
0
Comments
-
Hi @adrian17,
Thank you for choosing Photon!
What you are doing is the following:
- Master Client sends RPC to everyone including himself.
- Inside RPC, every client will instantiate two GameObjects locally and tell everyone else to do so (done by PUN automatically)
- Inside RPC, every client will rename gameObjects locally only.
So:
I would just use another RPC to rename or useIPunInstantiateMagicCallback
or custom instantiation data for this instead. You can find more information here.1 -
Thank you. This help me a lot.0