Multiplayer: syncing variables and sending messages

0 favourites
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hello everybody,


    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.

  • The question 2 is similar with that peer could not receive the message which sent by itself.

  • 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.

  • 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.

  • 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.

  • 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.

  • 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.

  • SgtConti - in the case of an RTS, you should be using Sync Object.

  • 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.

  • 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... ^^^

  • Thanks jayderyu i finally got it.

    Sync Unit variable Count

    On new Unit -> Set Unit Instance variable Count to GlobalVariableUnitCount

    -> Add 1 to GlobalVariableUnitCount

    and then in the message from the peer i send the variable with the action.

    On the host side, i compare the variable with the message

    took me some time to figure out how to make it as efficient as possible, but now it works.

    Thank you so much, i hope i can finish the RTS Multiplayer (alpha test) in the end of the week,

    ill be glad to give an demo to those who want to see the multiplayer plugin working on an RTS

  • SgtConti


    Did you finish that RTS demo with multiplayer?


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • irina yes, i finally got it to work some weeks ago, but since Node-Webkit is currently not supporting WebRTC i can't ship the demo :/

    but there is expected a new NW version in the next 1-2 weeks with WebRTC support.

    So if you'll follow this Twitter, i will tweet there when the demo is being published

    • Conti
  • i dont use twitter... got facebook page?

  • irina yeah sure, this one

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