Hi,
sending reference of GameObject is tricky and needs some special work indeed.
It's possible to send reference of networked GameObject because they have a unique ID across the network, but for regular non networked object, it's prone to issues because the Id's could be different.
the worker demo is using dedicated RPC to send to designated player, for the chat, check it out and see how it's implemented. It's not efficienty to send an RPC to all where only one will need it especially if the sender knows the receiver. So I would put effort into making this right to avoid too much traffic and messages per sec ( which will result in higher costs for cloud hosting).
bye,
Jean
Alright I solve my first issue but I can't help to think that this must be a huge issue for like everyone designing a multiplayer game and using RPC.
A very common thing in a multiplayer game is that one player have a skill/magic/etc. that affect another player in some way. How can't there be an easy way to reference another game object in the scene when this must be one of the most common actions regarding multiplayer?
For instance. In my game one player can use a magic spell that turns another player invisible. I have a empty gameobject acting as a "Spell manager" that receives all the RPC calls and then send out the local action that should be happening on every local machine. This "Spell manager" needs to reference the different players to know what action/spell should affect what player.
So in the case with the invisibility spell, The "spell manger" receives that call from the sending player but is unable to locate what player it should turn invisible (deactivate the graphic renderer) because the sending player can send a game object reference with the RPC call.
Sure, the player can send a string with the player name, and the "Spell manger" use "find game object" to find that game object in the scene, this feels very slow and inefficient, right?
I feel like I must misunderstand how to use these things properly.