playMaker

Author Topic: Send Raycast hit object info to other players using Photon  (Read 721 times)

vinitambini

  • Playmaker Newbie
  • *
  • Posts: 4
Send Raycast hit object info to other players using Photon
« on: June 05, 2021, 01:37:33 AM »
 Hi all,

I'm having trouble with the logic behind shooting in Playmaker + Photon. I hope you guys can help me.
I'm no coder, so that's why I'm using playmaker and maybe this is a stupid issue for a proper coder.
Anyway, here's what I have.

Player 1 creates a room (Master) and also instantiate NPCs.
Player 2 joins room and gets the movement/rotation/animation of NPCs from master.

So far so good.

Player 2 is a shooter. When player 2 clicks mouse's left button, it fires a raycast. Player 2 can store the hit object locally, but does not send that information to other players because RPC works with Strings only, not game object

I tried getting the Actor number of the NPC that got hit and then send the Id number as string to the other players. However, when I use the "photon network get players properties" action, every NPC has the same Actor Number as the master (player 1), since he was the one who instantiated all NPCs.

How can I make this?
How can I send which NPC was hit to the other players?

I hope I made it clear.

Thank you in advance :)

LordHorusNL

  • Beta Group
  • Full Member
  • *
  • Posts: 226
Re: Send Raycast hit object info to other players using Photon
« Reply #1 on: June 05, 2021, 04:23:44 PM »
Use the PhotonView ID from the hit object instead.

I don't have Photon installed however I believe there should be an action like "Get PhotonView ID" or something along those lines included with the Pun package.

vinitambini

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Send Raycast hit object info to other players using Photon
« Reply #2 on: June 05, 2021, 07:32:08 PM »
Hey LordHorus, thanks for replying.
I found this action action here. I'll give it a try  :D