SyncObject for timer doesn't sync

0 favourites
  • 5 posts
From the Asset Store
Sync animations, animation frames, mirror state, sounds and anything else using these methods.
  • Hello there!

    For my game, after the host pressing start in the lobby I want to have a 5 second countdown so the players can prepare for the game to start.

    To not get out of sync I do not just use a multiplayer message for the timer to start, but instead I use an invisible sprite object that I named SyncObject. It will have instance variables that I want to keep in sync with all of the, up to 4, other peers with the sync instance variable feature.

    The first problem I face is that this SyncObject object will not be created on the peers side If I create that object on the host side. It will only be created if I drag and drop the SyncObject inside the editor on the layout, but not if I create it inside the eventing system with create object.

    The second problem is that although I drag and drop the SyncObject and it will be created on the peers side the instance variable will just not sync.

    When the timer is started I set the timer variable of the SyncObject to 5 on the host side and after every 1 second I substract 1 from it. But it remains 0 on the peer for the whole duration.

    What am I doing wrong? As always, thanks in advance!

  • Your sync action is in the host group. I believe it needs to be done for all clients.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • send a message with how long until it start and date.now and be done with it

  • oosyrag When I put the sync initialization events in the common group (active on host and peer) then on random either the host or the peer will have 2 SyncObjects and the other one will have one. Even when I only drag and drop one SyncObject on the layout inside the editor.

    I can further troubleshoot that later but maybe someone already sees the solution.

    eleanorjmorel About the date.now yeah I could possible do that but I need a working SyncObject anyway for other stats so I will just focus on finding a solution for syncing local variables. But thank you for the advice. Always good to know alternatives.

    .

    Edit:

    Okay I got it to work.

    For everyone having the same issue:

    You must set the multiplayer sync object events on both the host and the peer side, even if that seems counter-intuitive and the documentation doesn't mention this. I thought the multiplayer object would be smart enough to tell the peers which objects to sync if it sends them updates of their states. After I set that up I was able to create the SyncObject object with the eventing system and it was then created on the peers side and everything is working now.

  • Oops sorry I thought I replied to this but I guess I didn't hit post. Glad you figured it out, but for the duplicate object issue, the peers should delete the original object placed manually on the layout upon connecting and confirming peer status. Only the host will keep/adopt the original object and sync it to the peers, then create additional synced objects for each peer if necessary.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)