playMaker

Author Topic: Bool not syncing in w/ PUN2 [SOLVED]  (Read 1544 times)

DevinFM

  • Playmaker Newbie
  • *
  • Posts: 9
Bool not syncing in w/ PUN2 [SOLVED]
« on: August 08, 2020, 09:02:21 PM »
Hi there, this one's been killing me all night, because I've used bools and Photon Networking before, but for some reason they won't sync here.
I've double checked that the Network Sync box is ticked, the FSM that stores my synced variables is being observed by Photon View, all that good stuff, and I know that's all working because the other variables I'm syncing across the network are working, but for some reason the bools will not change.

It should be very simple, I would like for PlayerA to press a button and have the bool change for PlayerB.

I have PlayerB getting the synced bool from the FSM that holds all of the synced variables every frame, storing the bool, then testing the bool.

I should note (though, I can't see why this would matter, but maybe it does) that When PlayerA presses the button, I am using the "Set FSM Bool" action and directly altering (well, trying to directly alter) PlayerB's bool that's synced over the network.

What am I doing wrong? Should I give up and just go with an RPC?
« Last Edit: August 09, 2020, 12:10:24 PM by DevinFM »

DevinFM

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Bool not syncing in w/ PUN2 [SOLVED]
« Reply #1 on: August 09, 2020, 12:26:56 PM »
I figured it out. For anyone who finds themselves here looking for help, my issue was fairly simple.

I was flipping the bool to true then resetting it too quickly for the network to pick up, and I was trying to bend some rules about using Photon in ways I shouldn't have.

I won't get into my wrongdoings, but the solution I found (which, there is almost certainly a simpler one) was:

When PlayerA presses the button, it changes PlayerA's Variable Network Sync bool to True, then back to false before looking for the button press again.

On PlayerB's computer (so when PlayerA is in the Photon state of "isNotMine") the PlayerA object is updating is looking for the Player a Variable Network Sync bool to change.

When it does change, it sends to a second state (again, this is the PlayerA object on PlayerB's computer) that changes a bool on PlayerB to True.

This worked, but only occasionally. The problem there was that PlayerA on PlayerA's computer was flipping the bool so fast that the network couldn't pick up a change. I added a "wait" action for 0.1 second (I tested a shorter time, but it would have the occasional screw up) to give the network enough time to sync the bools.

If you're having this problem and this doesn't make sense, reach out to me here or on Twitter (@OhGoshOhJeez) and I'll help. Again, there is almost certainly a better way to do this. Never forget that I am an idiot.