How do I Sync Both ways: Multiplayer?

Get help using Construct 2

Post » Sun Nov 16, 2014 3:50 am

Hi, so I am making an online multiplayer game and both players can summon objects.
So, I use Multiplayer Sync (and it's implied that there's a host and a peer).

The problem is that the sync only works from the host to peer only.
But, I want the peer's changes to be transferred to the host as well so that the "sync" is both ways rather than one.

Is there a way I could do that?

Thanks for helping!
B
4
Posts: 17
Reputation: 234

Post » Sun Nov 16, 2014 6:30 am

nzhu wrote:But, I want the peer's changes to be transferred to the host as well so that the "sync" is both ways rather than one.

The plugin doesn't work that way, the host should always be authoritative over changes. In your case when you want the peer to summon an object, what you can do is to have the peer to [action: send message] to the host, then at host, on peer message, you spawn the object on peer behalf. That way the object will be automatically sync over all peers.
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Sun Nov 16, 2014 7:54 am

DuckfaceNinja wrote:
nzhu wrote:But, I want the peer's changes to be transferred to the host as well so that the "sync" is both ways rather than one.

The plugin doesn't work that way, the host should always be authoritative over changes. In your case when you want the peer to summon an object, what you can do is to have the peer to [action: send message] to the host, then at host, on peer message, you spawn the object on peer behalf. That way the object will be automatically sync over all peers.


Thanks for your Reply. After thinking about what you've said, Here's my new logic:

1. Peer creates object.
2. The object's created coordinates are stored in two global variables, objectX, and object Y.
3. Then send two messages to the host each containing the global variables, objectX and objectY
4. Then I want to sync the sent messages to the same global variables, except on the Host's side.
5. Then from the host side, I can do action, create object at the locations of the global variables.

I want to do the above, but I'm having trouble at step 4, figuring out how to set my Host's global variables to the sent messages of the Peer's equivalent global variables, objectX and objectY.
B
4
Posts: 17
Reputation: 234

Post » Sun Nov 16, 2014 2:07 pm

It should be:

1. On start layout sync object (position or None depends on cases), if object moves every tick, use position, if static, use none. Your case should be None.
2. Peer send message object.X&"_"&object.Y
3. Host create object at x=tokenat(MP.message,0,"_") y=tokenat(MP.message,1,"_")

Should be just that. Your no 4 is unclear, you need to be more specific on what the global variable is for.
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Mon Nov 17, 2014 1:28 am

O wow it worked!!!
Thanks so much!

I had no clue what Tokenat meant until now. Thanks!
B
4
Posts: 17
Reputation: 234


Return to How do I....?

Who is online

Users browsing this forum: tdcostas and 6 guests