How do I make this multiplayer sync work?

Get help using Construct 2

Post » Fri Jun 06, 2014 3:57 am

I'm playing around with a test game board that will let players move pieces around a grid. Right now, as far as I can tell, I have all of the necessary events to make this work (client input, syncing, etc.), but it's only working for host input. When the host moves a piece around, everyone is seeing it and it's staying where it should. When a peer moves a piece, it's only moving on their screen, and snapping back when released. So, sync works, piece moving works, but not peers moving pieces "for real"; it looks like a client input issue but I can't find the problem. Here's the thing. Feeling clueless. (Yes, a lot of this is chopped out of the tutorial files. Like I said, playing around. Forgive me!)
You do not have the required permissions to view the files attached to this post.
B
28
S
5
G
1
Posts: 62
Reputation: 2,392

Post » Fri Jun 06, 2014 3:26 pm

Image
B
28
S
5
G
1
Posts: 62
Reputation: 2,392

Post » Fri Jun 06, 2014 4:09 pm

It looks like peers update ControllingUser, but that information is never sent to the host, so the host never knows which players are trying to move the token. If the host never moves the token, on the peers any changes will be overridden as the object is synced with wherever it is on the host.

In general anything the peers do needs to be sent to the host, and then the host actually does it.
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,351

Post » Fri Jun 06, 2014 10:54 pm

Oh hey, thanks for the reply! So... hm. Is this not the proper way -- OH! The Instance variable! I get it!

[testing...]

It works! Thanks so much.
Last edited by Mike Mead on Tue Sep 29, 2015 2:56 pm, edited 1 time in total.
B
28
S
5
G
1
Posts: 62
Reputation: 2,392

Post » Thu Jun 26, 2014 3:37 pm

Hi. I tried something similar and added a new client input value and the value is stored in an instance variable of a sprite which was added to "Sync", too.
I modified the Pong demo and when I added a new variable to the paddles it worked fine. But as soon as I add a new object with synced variables it seems nothing is sent to peers or received by the host anymore. :/

On Start of Layout:
Image
Peer Code:
Image
Host Code:
Image

The only difference between paddle and the tiledBG is that only the paddle (and only 1 object has to be?) has the "Multiplayer Associate" action.
When I open it in 2 browser windows and hit space on the Host the left number is increaded (in both windows) and if I hit it in the peer window the right number increases. But the value of the TiledBG (or other sprites I tried) is not updated. Does anyone know why or how to fix this?

btw: Is there a way to restore/redownload the original examples when you accidentially overwrite the sample file?
Bl4ckSh33p-Soft - Custom Software and Indie Games
B
56
S
17
G
6
Posts: 748
Reputation: 9,420

Post » Thu Jun 26, 2014 6:36 pm

Hi. I talked to someone with a similar problem and he used Boardcast message to send data and variables and it seems to work fine for him.
Is the "Sync Variable" action (initialized on Startup) only working for the player object or should it work with all objects?
Bl4ckSh33p-Soft - Custom Software and Indie Games
B
56
S
17
G
6
Posts: 748
Reputation: 9,420

Post » Fri Jun 27, 2014 9:40 am

OMG! I think I found the problem. I forgot to destroy the objects when you are the peer. It seems to work now but the size/scale of objects is not synced.
I reduced the object size on the host to make it fit better into the UI but on the peers the synced objects are all much bigger.
Bl4ckSh33p-Soft - Custom Software and Indie Games
B
56
S
17
G
6
Posts: 748
Reputation: 9,420

Post » Sat Sep 26, 2015 4:10 am

I am having issues with the ball going through the peer paddle. Does anyone have a fix for this??
B
4
Posts: 15
Reputation: 206

Post » Tue Sep 29, 2015 2:56 pm

Hi, old thread! Are you sure you have the "bounce" code under the host section of your project, and not the peer section?
B
28
S
5
G
1
Posts: 62
Reputation: 2,392


Return to How do I....?

Who is online

Users browsing this forum: Lordshiva1948 and 6 guests