Multiplayer: syncing variables and sending messages

Discussion and feedback on Construct 2

Post » Tue Mar 25, 2014 9:23 am

Hello everybody,
@Ashley

Again, I don't know if the following are bugs or it's intended like that, but definitely it needs some clarification:

1. I have a static object on stage, say a text box, and I want to sync only its variables. If I do something like this:

Sync Textbox with none
Sync Textbox variable Somevar

Nothing get synced, it will only work if I sync the position of the Textbox, which actually creates new instances of Textboxes on peer and syncs the position of the object which will never move.

2. Host: Broadcast tag "Sometag" message "SomeMessage".

The event "Multiplayer onPeerMessage"Sometag" is not get triggered on the host. May be it seems redundant to send the message on itself, but this is crucial for syncing purposes.
B
45
S
11
G
4
Posts: 517
Reputation: 7,393

Post » Tue Mar 25, 2014 9:31 am

The question 2 is similar with that peer could not receive the message which sent by itself.
B
108
S
26
G
271
Posts: 4,471
Reputation: 151,777

Post » Tue Mar 25, 2014 12:13 pm

1. You probably do not want to sync a whole text box, because that will create and destroy instances to match the host. You should probably just leave it not synced and send messages to update variables. (It's a little unusual to have variables in a text box since they're just for text entry, perhaps you want globals instead?)

2. It's by design that if you send a message over the network, you don't receive it yourself. See the chat tutorial for an example of handling it locally at the same time as sending off the message.
Scirra Founder
B
397
S
236
G
88
Posts: 24,423
Reputation: 194,560

Post » Tue Mar 25, 2014 12:34 pm

Ok, now I get it. The whole syncing functionality is only for real time action games with moving objects, shooting etc. I will build everything with "send message". But frankly speaking it's a bit pitty, that you can't use syncing for turn based stuff.

In my case the text box is used to show the turn time. It has timer behavior in it. I used variable to sync the turn time between peers and hosts. But now I will do it differently.
B
45
S
11
G
4
Posts: 517
Reputation: 7,393

Post » Tue Mar 25, 2014 3:18 pm

@Ashley - I think that, particularly for but not limited to multiplayer, some variable loops would be very handy. I find things can get quite messy when dealing with large numbers of variables, and some options like 'for each text variable' would be great.

Not only would it save a whole lot of time manually adding each one to an event, but also save potential deep-seated glitches from happening where you miss one variable in amongst a lot of too and fro. Folders/sorting would also be appreciated, but that's something else.
B
28
S
8
G
5
Posts: 429
Reputation: 7,007

Post » Tue Mar 25, 2014 3:27 pm

@Ashley , if the peer needs to send a message to change a instance variable, how do the host pick the instance, if there are more then one?
That is a bit problematic for an RTS with multiple different units.
"It's done when it's done"

Shadows of War
Buy on Steam ;)
B
24
S
10
G
7
Posts: 253
Reputation: 4,931

Post » Tue Mar 25, 2014 3:51 pm

Yes, I noticed that syncing multiple units which represent a peer could get tricky, especially if you use local input prediction. There's a strange movement artefact, like units are slowly moving to their destination places.
B
45
S
11
G
4
Posts: 517
Reputation: 7,393

Post » Tue Mar 25, 2014 4:13 pm

@SgtConti - in the case of an RTS, you should be using Sync Object.
Scirra Founder
B
397
S
236
G
88
Posts: 24,423
Reputation: 194,560

Post » Tue Mar 25, 2014 4:43 pm

@Ashley , yes, but as said, if the peer selects units and then for example changes an Instance variable of the selected units from 0 to 1 (Movement Variable)
How can the peer give the host information about what unit he actually have selected?
It could be that there is something im missing, in that case im sorry.
"It's done when it's done"

Shadows of War
Buy on Steam ;)
B
24
S
10
G
7
Posts: 253
Reputation: 4,931

Post » Wed Mar 26, 2014 12:22 am

@sgtConti
Custom variable ID of the unit that needs to be shared. Possible based on order of creation and type.

Also the Host doesn't need to know the selected Unit. The host needs to know the action result and Unit ID... ^^^
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,028

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests