Some multiplayer questions - could someone please educate?

0 favourites
From the Asset Store
The official Scirra Multiplayer Signalling Server for helping peers find and connect to each other
  • Thanks ASHLEY. That technique worked! Now I am trying to add a textbox to each sprite and move it along with the sprite in multiplayer mode...The way I went about it was by adding a container textbox object and tested it..However the textbox doesnt move along with the sprite...Looks like sync doesn't sync container objects? Do I need to repeat the same code that I did for sprite to move the textbox as well?

    Edit - I think I got the answer in the forums from Ashley's response to one of the bug - "Closing as not a bug. You only sync one of the objects, so the other object in the container will be created, but not synced".

    But I couldnt understand why sync - position cannot happen on container objects...wont that be a good/required feature?

    I would imagine you just have to sync every object in the container (and since not every object in a container share the same X and Y coordinates, as some may be just static, syncying them by default would be unessecary)

  • I would imagine you just have to sync every object in the container (and since not every object in a container share the same X and Y coordinates, as some may be just static, syncying them by default would be unessecary)

    Actually only one object is required to be sync in the container, for other object in the container, they would have to be positioned and pinned on peer side upon creation, since they are spawned at default (-1000,-1000). Syncing all objects would kill the bandwidth though, it's unnecessary when they already have the coordinate reference from the synced object. This would apply to animation too.

  • Sync does not sync anything other than what you explicitly tell it to, in order to save bandwidth. Nothing is automatically included, not even containers. If an object is always positioned on top of another, then syncing it as well is just a waste of bandwidth - you can just position it on top of the other object on the peer without needing any extra data to be sent.

  • I am exploring Multiplayer features and hence several questions...As I find answers, I am very excited about the potential it has...Please bear with me...

    My question is - Is there any limit on the size of multiplayer.message? I converted sprite image to base64 image string and sent it as a message...Good news is that it works for images upto the size of upto 300px by 300px (around 13kb size) or so...However when I try to send something like 60kb size (600px by 600px) a strange thing happens - Multiplayer kicks the peer out! OR the message is not received at the peer side forever...Could you please tell me how this can be circumvented OR what is the limitation on messaging size/feature? BTW, I am sending the message from host only after "On image URL loaded" condition...I know that this is async on host...but isnt supposed to send the message to peer anyway whenver that happens on host? And why it is that sometimes the peer gets kicked out?

    Thanks....

  • I am exploring Multiplayer features and hence several questions...As I find answers, I am very excited about the potential it has...Please bear with me...

    My question is - Is there any limit on the size of multiplayer.message? I converted sprite image to base64 image string and sent it as a message...Good news is that it works for images upto the size of upto 300px by 300px (around 13kb size) or so...However when I try to send something like 60kb size (600px by 600px) a strange thing happens - Multiplayer kicks the peer out! OR the message is not received at the peer side forever...Could you please tell me how this can be circumvented OR what is the limitation on messaging size/feature? BTW, I am sending the message from host only after "On image URL loaded" condition...I know that this is async on host...but isnt supposed to send the message to peer anyway whenver that happens on host? And why it is that sometimes the peer gets kicked out?

    Thanks....

    That would depends on the limit of packet size, I'm not sure what is the packet size limit for webrtc, but I'm assuming 64kb. I don't think sending pictures in MP is a good idea and is not what it was built for. I would understand if this involve custom player avatar transfer, but the avatar shouldn't be that big. Furthermore, this is very bad bandwidth management, I suggest look for other method of loading image.

  • DuckfaceNinja - Thanks for your perspective. However I think there could be a limit on messaging size but I dont think its a bad bandwidth management especially when the world is already talking about video streaming using webrtc...If the limit is on message size, then I could probably think of split/concatenate approach for larger messages...This approach brings up another interesting question - It would be nice to have a event - Multiplayer - On message sent "tag" ? Even if we keep my current problem aside, this event could be helpful for sending serialized messages one after another as well?

  • In a game context, I think the largest message I ever transferred are json array. How do you intend to use MP anyway?

  • I am planning to develop a tool using MP ( which is not in gaming context ) and sorry that I cannot disclose more than this...

  • I have to spawn a new sprite on peer or host whenever the user double clicks on a screen...While I was able to get this working, I am not able to update the sprite.peerid with the peerID's of the user who creates them...I am using "Sprite - oncreated" event on peer and then assigning it to multiplayer.peerID...(as per the example multiplayer.peerID is supposed to contain the peerID whenever sync object creates a sprite on the host)...Strangely multiplayer.peerid gets set only for very first sprite that gets created on the peer / host...The sprites that get created from then on have blank values in their peerid instance variables..I am sending a message to host to create a sprite whenever peer double clicks on screen...

    DuckfaceNinja OR help or have you encountered such a situation?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Also I have noticed that if sync - variable happens to be a text, then it doesnt sync? It only syncs number type variables...

    Ashley, I have referred the tutorials and examples but couldnt find any answer to this. Could you please help?

  • 'Sync instance variable' doesn't support text, only numbers. The manual entry didn't mention that so I updated it to include that.

  • Thanks ASHLEY. I have also noticed that in Pong example -> Peer group - on-created paddle event - set Paddle.peerid to multiplayer.peerid works only for one single instance of Paddle. In any game, lets say if I want to create multiple paddles (by sending create message from peer to host , using sync object) then the remaining instances of paddle on peer side doesn't get set to multiplayer.peerid...they are getting set to blank. The Pong example says that sync object should automatically get the multiplayer.peerid on peer side when a paddle gets created...This seems to work only for the first instance of paddle on peer side and doesnt work for remaining instances...

  • Have you looked at the real-time game example? Pong is hard-coded to use 2 players, whereas the shooter game works with any number of players.

  • Ashley, I did look at real-time game example...Even in real-time game, there is only a single instance creation of a sprite called "Peer". But my question is even there are only 2 players or "n" number of players, I want to create multiple instances of sprites for each Peer...And I want to associate all instances of sprites created by a particular peer to that peerid....In such case, inside the peer group if I have an event like - on-created sprite event - set Paddle.peerid to multiplayer.peerid action sets the peerid only for the first instance of the sprite...The peerid for all other instances is blank using this approach...somehow sync object is not syncing for the remaining instances of peer sprites ...Hope I am clear..

  • I have to spawn a new sprite on peer or host whenever the user double clicks on a screen...While I was able to get this working, I am not able to update the sprite.peerid with the peerID's of the user who creates them...I am using "Sprite - oncreated" event on peer and then assigning it to multiplayer.peerID...(as per the example multiplayer.peerID is supposed to contain the peerID whenever sync object creates a sprite on the host)...Strangely multiplayer.peerid gets set only for very first sprite that gets created on the peer / host...The sprites that get created from then on have blank values in their peerid instance variables..I am sending a message to host to create a sprite whenever peer double clicks on screen...

    I'm not sure if you're having the "not yet created" issue here, but I think this might be the case. I have issue before with similar like this but different. Ashley introduced wait for signal a few release back which solved this issue.

    I'll explain my case, I'm not entirely understand the technical work on the back of it but I hope this help:

    I think sync object is sync 1/30 second so there's a chance that the data arrive is not in desirable order when used in parallel with send message. However, reliably ordered message are guaranteed to arrive in order if it is a case of between broadcast and send. There's a chance the sync data arrived the tick before the send message arrive which theoretically confirms why wait for signal works.

    Tl;dr, experiment with wait for signal in the on created event. Actual snapshot of my simplest case:

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