0 Favourites

[Online multiplayer question] Syncing Objects

  • I was messing around with Construct 2's multiplayer and it was going pretty okay for a while.

    I was making a top-down cooperative dungeon crawler and things were going okay, but he main thing I was fighting the whole time was the lack of responsive controls for peers when I was following the multiplayer online tutorial.

    Even with the predictive movement, peers were jittering around after having stopped moving which annoyed me to no end.

    I'm not really concerned with cheating in a cooperative game, which was what was discussed in the tutorial, so I had to implement some workarounds where the peer sends data to the host (for movement) and the host syncs it back where it updates your position for other peers, while not making corrections to your own.

    Had to do some more work arounds for swinging a sword too.

    But when I started working on projectiles, I started running into more problems which ended up with me creating projectile dummies for the peer and disabling projectiles that were synced back from the host.

    I thought that there must be some easier way to do this, and so I thought about it for a while and realized it would be much easier if the sync objects function could be toggled to sync to specific peers instead of all of them, all the time.

    So my question is, is there an easier way for a peer to create a sprite, continuously relay the sprite's data to the host, and then have the host sync it back to all peers instead of the one that created the sprite?

    That would basically fix a lot of my problems with how multiplayer is handled.

  • I doubt that there will be any changes made to the multiplayer plugin for now or in the future.

    However I also had to deal with issues like that and I found a workaround for it which Ashley does not recommend to use.

    Simply get the coordinates or any information you need and sync it up as chat/text, how you fetch the information is up to you.

    Again it is not recommended to use this method since the object sync is more optimized for lag prediction and so on,

    only use it if your game really requires it. (Mostly games which require precise movement profit from this workaround.)

  • multiplayer plugin is full of bugs > dont use it

    instead use websocket + nodejs

  • I can suggest you try out the Photon Cloud plugin. Very easy to set up and get working. I'm using it for my game and it's great.

  • TheRealDannyyy

    Yeah, I knew someone who tried to sync stuff up with the messages and that did not work out.

    mahdi71

    The C2 page for websockets says definitely don't use websockets for real time games.

    tunepunk

    Could you go into a little detail on how this works?

    I have no idea what this is or does

  • Fervir It's basically a cloud server that handles all the multiplayer stuff. There's no host or peer like the regular multiplayer. You connect and send data like movement, rotation, position, whatever through the cloud server to all other users in the same room. The user can create their own private rooms on demand, or join random rooms. I think each room can handle up to 16 players at the same time. That's basics of it.

    Check out this thread https://www.scirra.com/forum/plugin-photon-cloud_t125222 or read some more at the http://www.photonengine.com

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • tunepunk

    Do you know how to get the Photon plugin to work with Pathfinding?

    Ive got a TD based game and all is working well, but i cant seem to get the Objects (enemies created ) to be in sync with the other players.

    I looked at the platform demo, but no luck.

    Would i need to raise a event for each object created? what if im spawning 100?

    Would love it if you could steer me in a direction. Thanks

  • Projectiles are difficult to code with the MP plugin because of the delay in creating and destroying objects.

    The workaround I've used is to sync an INVISIBLE authoritative projectile via the host, and have create a visible sprite on the peer side for local input prediction. When the invisible host projectile gets synced, the local visible projectile will smoothly correct its position. On the host side, the "true" projectile will spawn a little farther forward with lag compensation, and peers can do similarly with reverse lag compensation

    This works best for slow moving projectiles. The difference in speed/angles upon spawning and catching up to the authoritative marker should be difficult to notice if done well.

    Basically, this is a recreation of the lag compensation and local input prediction systems for movement already baked into the MP plugin, except for the purpose of creating and destroying objects.

    For faster moving projectiles, this may not be ideal and it may just be best to show peers delayed, synced objects. This issue is not unique to the multiplayer plugin and is more an issue with netcode in general - you'll have to deal with the lag somehow in the end.

    If you don't care about an authoritative host, then you can just ignore the sync functionality all together, and have each peers update each other with messages. It will work as you described - the host will receive a message from the peer, and can relay a message to all peers with the contents and maybe a tag to identify which peer it comes from. This doesn't solve the lag issues though, which you'll still need to account for.

  • cliffordwh Pathfinding I'm not exactly sure what you could do with. I havn't looked in to that. But you should be able to just sync the start and end positions. But only have 1 actor trigger. You can check the lowest actorNr to be sort of the Host, that handles all the pathfinding, the rest of the users, don't calculate paths, otherwize there will be conflicts probably.

    If you want to create 100 objects. Send with the event the ammount to be spawned as well. For example 100, then. Then when the actors recieve the event.

    Repeat (Photon.PhotonData) times. - > Create objectSprite

    The best is to send the content of an array through photon as JSON. Then you can send a lot of stuff in 1 event. Check the Photon examples, (I think it's the fish tank) there's example of how they do that.

    Using this way you can send X, Y Rotation, Speed, whatever you want in one single event, just populate the array with everything you need to send at 1 time.

    If you're spawning something randomly, make sure only one of the actors triggers the event, then send all the random positions through photon to the other actors. If all actors calculate random positions they will all have different random positions. (Not synced)

  • tunepunk, thanks for the logic on that. Makes sense what you saying. Yes i am making use of the Array example which is great!

    Thanks again, will give it a bash

  • Fervir - just out of curiosity, did you end up switching to photoncloud? I've got player syncing working pretty well with the multiplayer plugin... but now I'm wondering about projectiles, and a few guys have recommended it so far.

  • I have the same problem with Syncing Objects, and my objects spawning randomly. when I open new tab at the Peer side and stay to another tab for a while then back soon, all objects will be delayed from syncing. maybe somebody or Photon Mastering ThePhotons can help me.

    any kind of help will be appeciated.

  • I have the same problem with Syncing Objects, and my objects spawning randomly. when I open new tab at the Peer side and stay to another tab for a while then back soon, all objects will be delayed from syncing. maybe somebody or Photon Mastering ThePhotons can help me.

    any kind of help will be appeciated.

    Known issue and it's all up to chromium at this point:

    https://bugs.chromium.org/p/chromium/is ... ?id=676036

  • even if Im using Photon?

  • even if Im using Photon?

    I'm not 100% but I think this should affect all multiplayer services based on WebRTC.

    If you read through the whole report you'll understand why it happens.

    Also of you're in C2's preview mode, set "Pause on unfocus" to off.

    It won't fix the mentioned issue above but that's generally a must, when working on multiplayer games.

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