playMaker

Author Topic: Send RPC To Certain Player?  (Read 2631 times)

KillerCreeper

  • Playmaker Newbie
  • *
  • Posts: 44
Send RPC To Certain Player?
« on: July 05, 2019, 01:51:29 PM »
How can I make an RPC send to only a certain player? I'm trying to make it so when a player shoots, it sends a raycast out. If the raycast hits a player, it will send an RPC to only them that will damage them.

I have this video as a reference. At around 10:00, the last line of code. How can I do that, but in PlayMaker?

KillerCreeper

  • Playmaker Newbie
  • *
  • Posts: 44
Re: Send RPC To Certain Player?
« Reply #1 on: July 07, 2019, 01:23:58 PM »
I think what I need is a way to send an RPC to a certain photon view ID.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Send RPC To Certain Player?
« Reply #2 on: July 08, 2019, 09:21:14 AM »
Hi,

 there is an action called PhotonViewRpcBroadcastFsmEventToPlayer

have you tried it?

Check out the chat system inside the playmaker photon demo, one player can chat to another directly, the same mecanism can be used for damage.

Bye,

 Jean

KillerCreeper

  • Playmaker Newbie
  • *
  • Posts: 44
Re: Send RPC To Certain Player?
« Reply #3 on: July 08, 2019, 01:18:45 PM »
Hi,

 there is an action called PhotonViewRpcBroadcastFsmEventToPlayer

have you tried it?

Check out the chat system inside the playmaker photon demo, one player can chat to another directly, the same mecanism can be used for damage.

Bye,

 Jean

I can't use PhotonViewRpcBroadcastFsmEventToPlayer because that requires a player name. I have a "remote player" that is a child to the player prefab. It has different colliders on each bone: head, chest, upper arm, lower arm, upper leg, lower leg. The raycast only gets these objects, which don't have photon names but they have photon ids.

Am I able to put photon names on those objects without it breaking anything?
« Last Edit: July 08, 2019, 06:15:37 PM by KillerCreeper »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Send RPC To Certain Player?
« Reply #4 on: July 10, 2019, 09:41:06 AM »
Hi,

 I am not able to make sense of your setup... everything inside a Networked Object belongs to one player, so I am not sure how you can have a network instance belonging to a player and some of its children belonging to other players.

 Can you clarify?

 Bye,

 Jean

KillerCreeper

  • Playmaker Newbie
  • *
  • Posts: 44
Re: Send RPC To Certain Player?
« Reply #5 on: July 10, 2019, 09:52:46 PM »
Hi,

 I am not able to make sense of your setup... everything inside a Networked Object belongs to one player, so I am not sure how you can have a network instance belonging to a player and some of its children belonging to other players.

 Can you clarify?

 Bye,

 Jean

How my setup is:
I have a remote player that is a child of the player prefab. That remote player is the player model. It gets destroyed if "Is Mine" is true. But the remote player is what the other players see that player as, basically.
On each bone of the remote player, they have a collider on it. (This is so it is more realistic and because it easily works with animations)

Overall though, I did get it working by just setting each bone object a photon name (e.g. Head, Lower Leg L, Upper Leg R, Lower Arm L, etc).
I highly doubt that that is a good way to do it, but it works for now and I can always find a better change it if I really need to.

Edit: I also removed the photon ids on them since they were useless and wasteful.
« Last Edit: July 10, 2019, 09:55:13 PM by KillerCreeper »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Send RPC To Certain Player?
« Reply #6 on: July 11, 2019, 02:44:30 AM »
Hi,

I think It's a case where like in VR you want others to see a human body, while the local player doesn't see himself. am I correct?

- you should have only one photonView per networked Object and its hierarchy ( you can have more, but it's not recommended, as it's very advanced).

- Send an RPC to that photonView, you either send one RPC with a string value defining more, or make several RPC, one for the head, one for the lowerLegLeft, etc, and your fsm receiving them rpc, will forward that to it's children properly.


 Bye,

 Jean