playMaker

Author Topic: Get Gameobject that sent a RPC call? [SOLVED]  (Read 7215 times)

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
Get Gameobject that sent a RPC call? [SOLVED]
« on: September 22, 2017, 08:57:24 AM »
Hi,

Is there a way to send other then strings with a RPC call? right now I need the receiver of the RPC to recognize who sent the RPC call, is there a easy way of doing this?

I can just send another string parameter with the name of the player, but then I need some kind of a "convert string to game object" with do not exist.

Any clues on how to proceed?
« Last Edit: September 28, 2017, 02:39:49 AM by djaydino »

shinodan

  • Full Member
  • ***
  • Posts: 180
    • Shinozone
Re: Get Gameobject that sent a RPC call?
« Reply #1 on: September 25, 2017, 09:41:25 AM »
(Edit) - In my experience using playernames for that sort of thing always leads me to a dead end.

Get and Send the photon ID instead as a string in the RPC call then on the receiving end use "Photon find by view ID" Which can get and store the gameobject of that ID. (you have the option to use the ID as a string anyway)

Regards,
Dan

:)
« Last Edit: September 25, 2017, 10:09:15 AM by shinodan »

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
Re: Get Gameobject that sent a RPC call?
« Reply #2 on: September 25, 2017, 06:10:56 PM »
(Edit) - In my experience using playernames for that sort of thing always leads me to a dead end.

Get and Send the photon ID instead as a string in the RPC call then on the receiving end use "Photon find by view ID" Which can get and store the gameobject of that ID. (you have the option to use the ID as a string anyway)

Regards,
Dan

:)

Alright! That actually sounds like a pretty good plan. I will check this out in the morning. Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get Gameobject that sent a RPC call?
« Reply #3 on: September 26, 2017, 04:04:41 AM »
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

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
Re: Get Gameobject that sent a RPC call?
« Reply #4 on: September 27, 2017, 07:45:28 AM »
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.

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
Re: Get Gameobject that sent a RPC call?
« Reply #5 on: September 27, 2017, 07:57:36 AM »
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.

SORRY! I just re-read what you wrote and know i understand. I used the method that shinodan described and it worked. I understand that its difficult to reference LOCAL game objects that is not instantiated by photon and do not have a unique photon id.

Thanks for the help, guys!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get Gameobject that sent a RPC call? [SOLVED]
« Reply #6 on: September 29, 2017, 02:57:13 AM »
Hi,

 yes, picking on all these network pitfalls and details is tricky :)

 bye,

 Jean