playMaker

Author Topic: PUN 2 Actions - Sync Scene Object Not Player  (Read 2755 times)

rcwongtk

  • Playmaker Newbie
  • *
  • Posts: 4
PUN 2 Actions - Sync Scene Object Not Player
« on: October 28, 2019, 06:30:30 PM »
Hello! Was hoping to get some help from anyone here using PUN 2 with playmaker. I wanted to create a game that has objects that anyone in the room can change the color of by tapping, that are scene objects and not the actual player objects.

Is there a way to have scene object colors sync through PUN 2? I made the objects change color when tapped, but it only happens on screen of the player that did the action and not the other players.

Help would be greatly appreciated! I have been trying for days and am at a total loss... Thanks in advance  :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PUN 2 Actions - Sync Scene Object Not Player
« Reply #1 on: October 29, 2019, 02:37:31 AM »
Hi,

 sure, this is totally doable :)

Scene Objects are owned by the master Client, knowing that, any player willing to change the color of a scene object, needs to send an RPC to the master Client telling it to do so ( in a polite way of course, the master client is ultimately the owner of that scene object :) )

You can send an rpc only to the MasterClient ( which reduce traffic as other players do not need to get this rpc).

the masterClient receives this rpc call, acknowledge it and changes the color of that scene object.


Another way could be to have the colors references in the room custom properties. Then Players simply set a custom room property with a key like "Object ID":<Color>

any player can listen to custom room property updates, and so each scene object can check custom properties, see if their ID color matches the custom property and if not, adjusts.

This second option could prove more dangerous, as there will be no in between manager, so depending on how complex your logic for handling color change is, you might want players to simply send an RPC and let the masterClient dispatch what to do with it.

Bye,

 Jean


rcwongtk

  • Playmaker Newbie
  • *
  • Posts: 4
Re: PUN 2 Actions - Sync Scene Object Not Player
« Reply #2 on: October 29, 2019, 12:45:17 PM »
Thank you so much Jean! This is a huge help, appreciate the quick response ^^

Numster

  • Playmaker Newbie
  • *
  • Posts: 9
Re: PUN 2 Actions - Sync Scene Object Not Player
« Reply #3 on: November 02, 2019, 04:42:21 AM »
I didn't understand the room properties part. Is there an exemple for that ?

(Thanks Jean for your work. In globality.)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PUN 2 Actions - Sync Scene Object Not Player
« Reply #4 on: November 05, 2019, 01:56:35 AM »
Hi,

 I am working on updated the example so that you can play with the custom properties.

I shall have it ready for end of this week.

Bye,

 Jean

Numster

  • Playmaker Newbie
  • *
  • Posts: 9
Re: PUN 2 Actions - Sync Scene Object Not Player
« Reply #5 on: November 24, 2019, 01:23:36 PM »
Ok nice :)