Case Status
Log In


Home ยป Add-ons»Photon Networking»Photon DemoWorker Sample»Photon DemoWorker Variable Syn…
Community Wiki

Photon DemoWorker Variable Synch Repository Fsm

We declare here all the variables we want to synch over the network.


This is a critical Fsm.

This Fsm plays a central role in synching your player in all running instances of the applications. you will notice that it doesn't implement any logic, it is simply a variable repository.

Synching variable Concepts

First, in order for all users to see what you are doing with your player ( where you are moving, what you do, like jumping, etc etc), you need to manually manage this. Why?, because this has to be efficient. in our case, we want to synch the position, rotation and character animation. On others games, the player might have a gun firing, or might have some more features.

The synchronization involves four distinct processes:

  1. Declaring a Fsm variable as "network sync" 

    This is where Playmaker really shines with it totally integrated synching system. by simply ticking this check box in an Fsm variable, playmaker automatically handle the network stream managment, where with conventional scripting, you would need to manually do this.

  2. MAKE SURE that the Fsm component that host variables synched over the network has a PhotonView component set to observe this Fsm. And MAKE SURE that you have also attached a PlayMakerPhotonGameObjectProxy component ( available from the "playmaker Photon" menu )

  3. Setting that Fsm variable when the owner of this player do something

    If you own this player instance, you are responsible to set the variable to reflect what the current state. for example, the position, so on every frame, if you are the owner, you will set the network synched variable hosting the position to the current position of your player

  4. Getting that Fsm variable when you are not the owner of the player and do what's required to match.

    If you don't own this player instance, you are responsible to get this variable, and in the example of the player position, set the player position to that position you got from the network synched variable.

So, here we have three network synched variables: "Animation (synched)", "Position (synched)", and "Rotation (synched)"

It is important to notice that only this Fsm has variable set to synch themselves over the network. This means in practice only one stream. If you spread variables to synch on more Fsm, you will essentially create more streams and it will lead to more bandwidth taken, so try to use this technic as much as possible to stay efficient and maximize network synchronization speed.

Look in the same gameObject for position synchrotation synch, and animation synch for the implementation and use of them synched variables.

Photon Events used



Last modified on 8/17/2012 8:51 AM by User.

  • RSS Feed