playMaker

Author Topic: Synchronizing Door through PUN [SOLVED]  (Read 4750 times)

vonpopov

  • Junior Playmaker
  • **
  • Posts: 98
Synchronizing Door through PUN [SOLVED]
« on: July 04, 2015, 09:07:14 PM »
Hi,

Could you give me tips, to make this possible (Synchronizing Door through PUN) without having a Stream for each door.

Could we imagine something like an arraylist which would get object by Tag (Tag : Door for ex) , and then synchronizing this arraylist ?

aye aye
« Last Edit: July 17, 2015, 02:53:24 PM by vonpopov »

600

  • Beta Group
  • Hero Member
  • *
  • Posts: 713
    • Flashing Lights
Re: Synchronizing Door through PUN
« Reply #1 on: July 04, 2015, 09:32:03 PM »
Hi, Im thinking about this too,
it is a matter of your game scale, but array idea could do it, get all doors by tag, then send (RPC event) to all that door x is open/close.
Doors could be all clones, but found by index, or hard named doors with numbers or maybe closest door to X player..

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Synchronizing Door through PUN
« Reply #2 on: July 07, 2015, 12:45:45 AM »
Hi,

 instead of using a stream, simply send a event. You can send an event only to the same Network Id, so when a door open the owner of the door sends an event to all it's instances over the network.

 Does that make sense?

Bye,

 Jean

vonpopov

  • Junior Playmaker
  • **
  • Posts: 98
Re: Synchronizing Door through PUN
« Reply #3 on: July 08, 2015, 09:46:17 AM »
Hi,

 instead of using a stream, simply send a event. You can send an event only to the same Network Id, so when a door open the owner of the door sends an event to all it's instances over the network.

 Does that make sense?

Bye,

 Jean

it makes sens, and i get it workin through "Photon View RPC Broadcast Fsm Event" ! wow thanks.

But, how to handle the situation when players connects "after" this event was sent. How to keep track of the state of the door through the server ?






« Last Edit: July 08, 2015, 10:02:13 AM by vonpopov »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Synchronizing Door through PUN
« Reply #4 on: July 08, 2015, 10:09:33 AM »
Hi,

 You can use "Room properties", and use this like the PlayerPrefs, saving the state of doors when not the default.

when a door is created, is checks against the room properties its state, if there is a property "Door x opened" then it knows it has to be opened, else it's closed.

and so everytime you open or close a door, simply save the state for that door in room Properties. you'll need to assign a unique Id for each door, but that's easily refactored.

Bye,

 Jean

vonpopov

  • Junior Playmaker
  • **
  • Posts: 98
Re: Synchronizing Door through PUN
« Reply #5 on: July 08, 2015, 10:46:39 AM »
Hi,

 You can use "Room properties", and use this like the PlayerPrefs, saving the state of doors when not the default.

when a door is created, is checks against the room properties its state, if there is a property "Door x opened" then it knows it has to be opened, else it's closed.

and so everytime you open or close a door, simply save the state for that door in room Properties. you'll need to assign a unique Id for each door, but that's easily refactored.

Bye,

 Jean

1/ i am not really aware of "playerprefs" could you point me a place where i could learn about, i am not sure those are used in the "worker demo"

2/ You say : "when a door is created" , actually my doors aren't instantiated, those a prefabs, part of the level. Is that a mistake ?

3/ When you talk about door unique ID, you mean through the photo view ?

4/ So, What you suggest is for each door a state which : set room custom properties to an eventually : "Door x opened" , and re-use this info at level loading ?

if you have details exemple to follow about room properties, let me know please.
i am actually learning PUN, i get a lot of success, my game run nicely, but if what you just said make total sens, i admit i am actually lost at doing it. :s


thx
« Last Edit: July 08, 2015, 10:48:39 AM by vonpopov »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Synchronizing Door through PUN
« Reply #6 on: July 09, 2015, 09:22:41 AM »
1/ i am not really aware of "playerprefs" could you point me a place where i could learn about, i am not sure those are used in the "worker demo"

no I was just pointing that you can think of room properties like PlayerPrefs, they persists, that's all.

Quote
2/ You say : "when a door is created" , actually my doors aren't instantiated, those a prefabs, part of the level. Is that a mistake ?

no that's fine, cause you only need to save a property int he room, which can be done from non networked objects, so your door simply sets a property of the room it is currently in ( de facto because your player is in the room, so everything inside the hierarchy can be safely considering it's in a room)

Quote
3/ When you talk about door unique ID, you mean through the photo view ?

nop, you decide of the id situation, you would simply create an fsm with a string "id", and simply use that to construct the property for example: "Door "+id


Quote
4/ So, What you suggest is for each door a state which : set room custom properties to an eventually : "Door x opened" , and re-use this info at level loading ?

yep, that's right. and your door can listen to the JOINED ROOM event or "ROOM PROPERTY CHANGED" event and adjust accordingly everytime.

Quote
if you have details exemple to follow about room properties, let me know please.
i am actually learning PUN, i get a lot of success, my game run nicely, but if what you just said make total sens, i admit i am actually lost at doing it. :s

I'll let you carry on experimenting with this a bit, and next week if you still can't get anywhere, I'll make a scene showing this. I am just running late this week, so please bump me next week and I'll work on it. thanks :)

Bye,

 Jean

vonpopov

  • Junior Playmaker
  • **
  • Posts: 98
Re: Synchronizing Door through PUN
« Reply #7 on: July 17, 2015, 12:31:23 PM »
Hi,

I experimented what you suggested this afternoon and i got it ... working !

As easy as :
1 - Each door has a start idle state which listen for "custom property room" (in my exemple Door1 State)
2 - If this state is true (at start all door have bool as false which mean "door closed") if yes, then it set that bool used locally to "open/true" and then go on state "open door" (which do the action of opening it).

So now, all i have to do is randomly generate an idea for each door prefabs, in order to create as custom propertie in the door as needed !

thanks !


« Last Edit: July 17, 2015, 02:53:33 PM by vonpopov »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Synchronizing Door through PUN [SOLVED]
« Reply #8 on: July 20, 2015, 09:22:59 AM »
Hi,

 Perfect!

Bye,

 Jean