playMaker

Author Topic: Sync moving scene objects in Photon?[SOLVED]  (Read 15992 times)

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
Sync moving scene objects in Photon?[SOLVED]
« on: December 26, 2017, 12:01:01 PM »
Hi,

So I have a made a multiplayer game that has some moving parts locally in the scene. The moving parts are stuff that has a constant speed and the players can't interfere with them. Like elevators etc.

So I wanted to save some network data and instead of syncing every moving little object I just checked when both players are connected and then restarted the scene for both players, making the game "start at the exact same time" and making all objects sync locally.

However, there is some latency in photon anyway so it was not a perfect sync. Is there a better way of syncing stuff like this?

Is it possible to check the ping in the start and then correct the starting time accordingly?

What is the best way to go about syncing stuff that the players can't interact/interfere with? (Like in a co-op game you want the players game to start at the same time.)

/Christian
« Last Edit: January 19, 2018, 01:14:24 AM by jeanfabre »

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
Re: Sync moving scene objects in Photon?
« Reply #1 on: December 29, 2017, 04:17:59 AM »
Anyone?

600

  • Beta Group
  • Hero Member
  • *
  • Posts: 713
    • Flashing Lights
Re: Sync moving scene objects in Photon?
« Reply #2 on: December 29, 2017, 07:56:25 AM »
Hello, maybe use RPC to set start movement.
Another idea, the host set Server Custom property, like bool and all players check it.

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
Re: Sync moving scene objects in Photon?
« Reply #3 on: December 29, 2017, 08:22:49 AM »
Hello, maybe use RPC to set start movement.
Another idea, the host set Server Custom property, like bool and all players check it.

Hi!

Thanks for you input. I feel like the RPC way is to heavy for just syncing the start.

Care to elaborate what you mean by sing Server Custom Property for this?

Bye,
Christian

600

  • Beta Group
  • Hero Member
  • *
  • Posts: 713
    • Flashing Lights
Re: Sync moving scene objects in Photon?
« Reply #4 on: December 29, 2017, 08:37:57 AM »
The RPC is not heavy at all, if not EveryFrame, same for Properties, sent only once similar as Global Event the movement processed locally on player’s side.

Photon will update values in Room properties, actions:
Set Room Custom Property
Get Room Property

The difference would be, with RPC the elevator would be ordered to move, but with Properties the elevator would check when to move.

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
Re: Sync moving scene objects in Photon?
« Reply #5 on: December 29, 2017, 01:01:33 PM »
The RPC is not heavy at all, if not EveryFrame, same for Properties, sent only once similar as Global Event the movement processed locally on player’s side.

Photon will update values in Room properties, actions:
Set Room Custom Property
Get Room Property

The difference would be, with RPC the elevator would be ordered to move, but with Properties the elevator would check when to move.

Alright, I should look into the properties.

I was a bit unclear what I meant with the RPC being heavy. It feels like its a lot more work, because then I need a FSM on every moving object in the whole scene.

It feels like if I only can get both all connected computers to restart the level at the exact same time, all the moving objects will be sync automatically which feels like the best and easiest way.

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
Re: Sync moving scene objects in Photon?
« Reply #6 on: January 02, 2018, 05:50:29 AM »
Does anyone know what is the best practice here? I really feel that the best way to go about is to try to restart the level for all players at the exact same time, and everything will be synced automatically.

Anyone with insight of how "real studios" do this?

600

  • Beta Group
  • Hero Member
  • *
  • Posts: 713
    • Flashing Lights
Re: Sync moving scene objects in Photon?
« Reply #7 on: January 02, 2018, 06:09:13 AM »
Not sure about "real studios", the restart on each pc would be in different speed/time, so you could only have some kind of wait system, that host wait until all players are loaded. With same RPC message for example.
But still it is not so reliable if you sync only the needed moving parts in demand.

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
Re: Sync moving scene objects in Photon?
« Reply #8 on: January 03, 2018, 04:14:14 AM »
Hi again!

Thank you for your time an patience. I do not want to sound ungrateful for you help, I really appreciate it, and you sure got more experience then me in this area but I fail to understand how your tip would help here.

If something would start the very first frame of the game, (if it is a RPC call or if it is just a both computer that's restart the scene) it all comes down to how fast the computers load right?

I feel I can't really wrap my head around this, fairly simple, issue.

I have not worked with room properties before, so maybe the answer lies there?

600

  • Beta Group
  • Hero Member
  • *
  • Posts: 713
    • Flashing Lights
Re: Sync moving scene objects in Photon?
« Reply #9 on: January 03, 2018, 06:05:35 AM »
Sure no problem, I can speak only of what I have seen/used.
So in multiplayer if you want the closest sync with Photon cloud, then use everyframe variable synch. Other than that not sure if there are any more precise measures, except Authoring server setup which is different setup, like all is calculated on server machine and all users get the same behaviour on synched entities. This is not included in Photon cloud and the implementation is different. I have not worked with it.

About the difference of things I mentioned. Basically as you say it is the same - level restart or RPC.
But if only sync the level restart, the difference with pc and network ping will only match once - at start. but if you use RPC or check for room properties, the example elevator would have more sync checkpoints. Sending RPC on movement start and movement end can speed up or wait for other player’s elevator to match its position. Some delay there will be anyway.

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
Re: Sync moving scene objects in Photon?
« Reply #10 on: January 03, 2018, 06:32:29 AM »
Sure no problem, I can speak only of what I have seen/used.
So in multiplayer if you want the closest sync with Photon cloud, then use everyframe variable synch. Other than that not sure if there are any more precise measures, except Authoring server setup which is different setup, like all is calculated on server machine and all users get the same behaviour on synched entities. This is not included in Photon cloud and the implementation is different. I have not worked with it.

About the difference of things I mentioned. Basically as you say it is the same - level restart or RPC.
But if only sync the level restart, the difference with pc and network ping will only match once - at start. but if you use RPC or check for room properties, the example elevator would have more sync checkpoints. Sending RPC on movement start and movement end can speed up or wait for other player’s elevator to match its position. Some delay there will be anyway.

Alright I see. I feel like the best way is to use a RPC call some how.  I'm not sure how to do this practically speaking.

So the elevator should stand still in the start and receive a RPC call to begin moving when both players are loaded? Or how should I go on about to fix this? How do I secure that the RPC call fires of in the right moment?

600

  • Beta Group
  • Hero Member
  • *
  • Posts: 713
    • Flashing Lights
Re: Sync moving scene objects in Photon?
« Reply #11 on: January 03, 2018, 06:50:23 AM »
I see it as my traffic lights, every X seconds an RPC is called to everybody switch lights. Could do something similar.
Can have maybe two events or one event with value like 0 or 1.
Host sends 0 - everyone update their elevators at ground floor, if 1 then drive up and stay there. With value in RPC you can even show a number of floor if there are more.

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
Re: Sync moving scene objects in Photon?
« Reply #12 on: January 03, 2018, 07:40:53 AM »
I see it as my traffic lights, every X seconds an RPC is called to everybody switch lights. Could do something similar.
Can have maybe two events or one event with value like 0 or 1.
Host sends 0 - everyone update their elevators at ground floor, if 1 then drive up and stay there. With value in RPC you can even show a number of floor if there are more.

Hmm.. okey. Maybe I forgot to mention that the elevators cant be interacted with. They just move up and down in a constant speed. I really really feel like there must be a easier way to just make them start at the same frame.

I saw that there is a "Photon transform view" component. It kinda feels like that is something I need? Does the other photon components work?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Sync moving scene objects in Photon?
« Reply #13 on: January 05, 2018, 06:10:12 AM »
Hi,

 There will always be latency, it's inherent to the network architecture and data transfer speed of the internet.

The most direct and performant way is to fire an RPC when the elevator starts. The latency can be counter indeed by using the server timestamp and do some math to move the elevator where it should be based on the difference between your time and the server time. But really, I doubt this is worth the effort.

 Can you describe why this affect your gameplay? maybe there is a better way to tackle this?

Also, have you checked TrueSync: https://www.photonengine.com/en-US/TrueSync

 it provided a determinist and 100% accurate simulation of the game on all players, if you are affected by latency so badly, maybe this is worth checking out ( reuqired coding, PlayMaker can not work with TrueSync because of the different way to store numbers)

 Bye,

 Jean
 

Krillan87

  • Beta Group
  • Full Member
  • *
  • Posts: 185
Re: Sync moving scene objects in Photon?
« Reply #14 on: January 08, 2018, 04:46:17 AM »
Hi,

 There will always be latency, it's inherent to the network architecture and data transfer speed of the internet.

The most direct and performant way is to fire an RPC when the elevator starts. The latency can be counter indeed by using the server timestamp and do some math to move the elevator where it should be based on the difference between your time and the server time. But really, I doubt this is worth the effort.

 Can you describe why this affect your gameplay? maybe there is a better way to tackle this?

Also, have you checked TrueSync: https://www.photonengine.com/en-US/TrueSync

 it provided a determinist and 100% accurate simulation of the game on all players, if you are affected by latency so badly, maybe this is worth checking out ( reuqired coding, PlayMaker can not work with TrueSync because of the different way to store numbers)

 Bye,

 Jean

Hi Jean!

I understand that there will always be some latency, but when I check the ping I got with Photon is around 40-50 and the "latency" is way above that, so I get the feeling it is no a latency issue but a issue of how my RPC/FSM are set up. There must be something else that cause the latency.

It does no affect my gameplay a whole lot in this game particularly but I want to understand why this happens so in future game I can correct it.

Okey so now I tried the RPC to fire of the elevator. (I've included a picture of the FSM). Basically the FSM just checks for how many connected players there are and if it is equal to the max player the game restarts and after the restart if the game is full it will not restart again but instead start the elevators (RPC Start game sends a RPC to start all the elevators on the scene)

Here is a video of the result:
https://ChristianE.tinytake.com/sf/MjI0OTg4M182OTQxNzEx

The first issue here is that the elevator on the right is not synced with the one on the left.

There is also a position issue with the player. I guess this comes from the lerp of the positionen? I there a good way of fixing this?

Is all this something that I just have to accept? Maybe there is impossible to get a more synced game?

/ Christian