Position Sync Problem(Solved)

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Position Sync Problem(Solved)

BoltGames
2018-01-10 21:07:38

Hello everyone I am developing a 2d soccer game for maximum 6 players.( for android and pc).
ı dont have any problem with syncronizing player controlled objects like "soccer players" but ı am having some syncronization issues with "ball" in the game. Everthing working almost perfect with my player objects (soccer players) but ı dont know how to implement a multi-player controlled object syncronization in my game.
Because of this problem ı am using photon transform view and photon rigidbody2d view for syncronizing my ball object. but they didnt solve my problem.

Now ı have 2 questions?
I am using free-trial pun (max 20 ccu) for development stage, is it possible that ı am having sync problem because of free-trial pun servers?

Second question, if there is no differences between free 20 ccu and paid service then how can ı solve this problem?

Thanks for your answers.

Comments

[Deleted User]
2018-01-11 10:44:52

Hi @BoltGames,

I am using free-trial pun (max 20 ccu) for development stage, is it possible that ı am having sync problem because of free-trial pun servers?

I don't think so. The servers should be the same for free and paid usage (except Enterprise Cloud).

Second question, if there is no differences between free 20 ccu and paid service then how can ı solve this problem?

These are problems due to lag / delay. Do you transfer ownership of the ball, if a certain player hits it or is the ball permanently controlled by the MasterClient?

One solution might be, to transfer the ownership of the ball to the player who hit the ball for the last time, so that this player can also apply the new force and direction to it which should make the entire simulation more stable. However I don't know, if this would be enough.

The better solution will be, to apply some kind of lag compensation, so that the simulation is most likely the same on each client. To see how this works I would like to recommend you taking a look at the Asteroids demo from the new PUN 2 Beta package. Having the package imported in a fresh project, you can look for the Spaceship and the Asteroid scripts. Both have a custom OnPhotonSerializeView solution which applies lag compensation. The Spaceship script additionally uses the FixedUpdate function therefore. For first tests you can basically copy and paste the OnPhotonSerializeView function of the Asteroid script.

Please let me know if you have further questions about this approach or to lag compensation in general.

BoltGames
2018-01-11 12:22:52

@Christian_Simon I am very thankful for your fast answer :)

I already tried to transfering ownership of ball object with "request ownership" method but it gave me an error and today ı tried to transfering ownership with "TransferOwnership" method after your answer and it mostly solved my problem :)
i am using "PhotonTransformView2D" script and ı set "Lerp" equal 10.

so my "ball object" almost moving perfect now.

Also ı will take a look PUN 2 Beta example.

Thank you for your help and have a good day. :blush:

EDIT: I implemented my own synchronization script and it is working perfect now. :)

MuMuDaDa
2018-03-07 10:30:36

@BoltGames wrote:

@Christian_Simon I am very thankful for your fast answer :)

I already tried to transfering ownership of ball object with "request ownership" method but it gave me an error and today ı tried to transfering ownership with "TransferOwnership" method after your answer and it mostly solved my problem :)
i am using "PhotonTransformView2D" script and ı set "Lerp" equal 10.

so my "ball object" almost moving perfect now.

Also ı will take a look PUN 2 Beta example.

Thank you for your help and have a good day. :blush:

EDIT: I implemented my own synchronization script and it is working perfect now. :)

Hello BoltGames ,

I am working on a dodgeball game but also have problem that player character are not perfectly sync.
Can you show me how do you implemented your own synchronization so I can get some idea how to fix mine?? Much appreciated!!

gadoy
2020-04-04 13:58:14

@BoltGames wrote: »

@Christian_Simon I am very thankful for your fast answer :)

I already tried to transfering ownership of ball object with "request ownership" method but it gave me an error and today ı tried to transfering ownership with "TransferOwnership" method after your answer and it mostly solved my problem :)
i am using "PhotonTransformView2D" script and ı set "Lerp" equal 10.

so my "ball object" almost moving perfect now.

Also ı will take a look PUN 2 Beta example.

Thank you for your help and have a good day. :blush:

EDIT: I implemented my own synchronization script and it is working perfect now. :)

Thanks for sharing your code dude

Yahya_Ali
2022-07-25 21:22:10

Hello,

I am working on a multiplayer game but also have a problem with players' positions sync.

Can I see your own synchronization too to fix my problem?

Thanks.

Back to top