playMaker

Author Topic: Network synchronization with playmaker and unitys built in networking [Solved]  (Read 2182 times)

Korvgubben31

  • Playmaker Newbie
  • *
  • Posts: 5
I'm having a problem where I want to predict an entitys movement so that it appears smooth on all clients. This means I only want to set his position forcefully when the position has been updated and other than that I just want to keep moving him in the direction he is facing. This is all done in 2d top down perspective so not much is getting synched, only synching his facing and his position. The problem I'm having is that I only want to set his position when an update to the position has actually been made ( when a position is received through the network ). Is there an event or something like that that fires when this happens or how can I do this position update only when needed?

Another strange thing that is occuring is that when I instantiate game objects over network ( players to be more precise ) they start out with a velocity. Anyone encountered this before and know how to solve it?

Thanks in advance! :)
« Last Edit: May 12, 2013, 10:26:26 AM by Korvgubben31 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

 I don't think that even Unity expose an Api to know when a value is sent over the network. Is it not a case where you should use "ReliableDeltaCompressed" for network synchronisation, and smooth out the result using interpolation?

In the photon demo, the animation trigger system would be a good starting point if you want to do something without reliable sync. instead of only relying on the position, also rely on the user input itself, and check for input changes, when the user input changes, catch up to the current position, else make a blend between your prediction AND the network position value. Making a interpolation between the two will give you a smooth result I guess.

as for initial velocity, is it extrem velocity? is the player actually not moving at all, and when instancicated on other computer, it gets a velocity anyway? to solve this, you could force the velocity to 0 the first frame after the instanciation.

bye,

 Jean

Korvgubben31

  • Playmaker Newbie
  • *
  • Posts: 5
Yes the velocity problem is exactly as you descibred it, will try what you said! :)

Unity however does expose a way to find out when a synchronization of data has been made over the network, I think it does anway. Isn't that what OnSeralizeNetworkView does?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

 OnSeralizeNetworkView is called regularly, it doesn't reflect that indeed a new value is coming. I don't think you can know if the value within OnSeralizeNetworkView is old or new.

 I might be wrong tho...

bye,

 Jean