Photon, PhotonView.RPC(), Reaching Instantiated Object, null?

Hi there,
I have instantiated a gameObject, across the network via the masterclient…

//called only from MasterClient
GameObject player = PhotonNetwork.Instantiate("player", Vector3.zero, Quaternion.identity, 0);

This object has a PhotonView attached. I want to set a particular setting on this (and its respective clones across the network. So I do this…

//called only from MasterClient
GameObject player = PhotonNetwork.Instantiate("player", Vector3.zero, Quaternion.identity, 0);
PhotonView pv_player = player.GetComponent<PhotonView>();
pv_player.RPC("m_setPlayerID", PhotonTargets.All, i);

My issue is that everything works, however the setting ( a color adjustment ) I make by looking at the value of i (the passed argument), only has an effect on the master client. The remote client, while it does clone and position the objects properly, does not adjust the color as requested.

Any ideas? Odd when everything else is synching.

Thanks

You could set some data along with the Instantiate. That would be way leaner than calling an RPC right after Instantiate.

There is no hint why your color setting code shouldn’t work.
You can have a look at the Demo Boxes in the PUN package. It comes with a component that applies something like a player-number per client (let’s say 1,2,3 and 4 for a 4 player game) and a color. That might do what you want and can be a blueprint.

1 Like

I got it working.
I forget what I had done wrong, but I was missing some connection. Essentially that code as originally posted is correct.

Thanks