Retrieve gameobjects from a network.player, adding multiplayer components

Hi,
I have a very basic but correctly working multiplayer non authoritative setting based on the official material.
I have the need to perform some specific client side actions on a gameobject, and I’m considering the RPC approach (for ease of implementation).

I have the following need:

1 - A gameobject (called A) performs an action that adds a component to it
2 - the gameobject A sends an RPC to the others telling that he has added the
    component
3 - the other gameobjects update their local copy of A, adding the component to A
    (for example determining its class from a variable name)
4 - ?
5 - profit!

besides point 4, about which I’ll worry about in the future, I can’t for the life of me figure how to correctly implement point 3, and tell the ‘others’ that SPECIFICALLY gameobject A has added the component.
I mean, surely you can identify a ‘player’ thanks to the RPC parameters, but what’s the way to associate a player with its multiplayer gameobjects?
I was hoping for something like

Gameobject[] networkplayergameobjects = Gameobject.Find(Network.player);

so that i could iterate and find by name, for example, but sadly there’s no such thing.

Any help is appreciated.

I might not be the best to answer this but my approach is to keep an Array of objects in the same order on all connected devices and then just check the index of the object i want to mess with and send that index over the network.

The player might contain a few objects like

PlayerPrefab

  • Character
  • Gun
  • Shield
  • and so on…

In the PlayerPrefab I just keep the reference array and networkview together with control scripts and other things vital to my character. I just perform an RPC call saying that object at index N should perform something.

Hope it helps :slight_smile: