peer sync

0 favourites
  • 11 posts
  • Hi

    Can the peer sync the UID of the instance?

  • Hello, explain your needs better...

    Do you want to know the UID of a peer?

    If so, just create a variable for example "UID_PEER"

    and on the host screen you put the peer's uid in this variable...

  • Now if what you want is to tell the host what "your local UID" is, even if other objects other than the host are created, just send a message with the UID in string form.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I mean, when the follower clicks on a subject, can it send its UID or should it just send the mouse coordinates?

  • Should the "peer state update" action be placed in the "mouse click event on the oubject" to send the click coordinates?

  • I want that whenever the peer clicks on an instance, its UID or at least the coordinates of the click is passed to the host. I used several methods but nothing happened. The peer cannot even change the instance variable.

  • (My apologies for weird formatting, couldn't get newlines to appear properly when I wrote this out).

    I wouldn't use UIDs, as they differ depending on when objects are created

    Say player 1 plays a game, then goes back to title screen and decides to host. And player 2 has freshly opened the game and joins immediately. Then player 1's UIDs will be higher numbers than player 2's. Even more true if you use the project setting to randomise UIDs.

    Its best to make your own ID system with instance variables.

    If you want a very basic "on click, send mouse x and y" then have some events:

    On click, and Is host

    multiplayer>broadcast message:

    Tag: ClickXY

    Message: mouse.x & "," & mouse.y

    ----------

    On click, and Is host (negated)

    multiplayer>send message:

    Tag: ClickXY

    Message: mouse.x & "," & mouse.y

    ----------

    Lets say you clicked at x=100 and y=200, the above expression will send a message that might look like this, two numbers with a comma between:

    100,200

    ----------

    Then add another event block for "on message ClickXY received", when it's host, let them broadcast the message so it reaches other players (if more than 2 players exist in your game).

    And on message ClickXY received (no need for "is host" as we want this event to apply to anyone), set instance variables for storing the coordinates, say we have variables called XMouse and YMouse:

    Set XMouse to float(tokenat(multiplayer.message,0,","))

    ----------

    Set YMouse to float(tokenat(multiplayer.message,1,","))

    ----------

    The tokenat() expression looks at the message (say the message is 100,200 ) and uses a comma as the separator, and the number 0 or 1 is "which part of the message to get", 0 being before the comma, and 1 being after the comma. "Float" means that we want this message to be read as a number rather than text (If you send messages that you want to store as text, you can remove "float()")

    Hope this helps!

  • I did the first part (host) using the instance variable (because the subject is synced) why can't the peer do this? Does the peer have permission to change anything or just send the input?

  • I made a game where peers can move objects... I used it as you thought... Send X and y and id.

    Using tokenat you can handle this.

  • I used this method and the problem was solved. But the reaction speed is lower. In the game where the speed of action is necessary, it may cause the peer to lag behind. Isn't there a faster way? Thanks

  • What is your movement system? Pathfinder?

    Because a quick reaction would be to continue using 8 directions via the set and get bit method.

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