How do I fix the multiplayer sync from peer to host?

0 favourites
From the Asset Store
The official Scirra Multiplayer Signalling Server for helping peers find and connect to each other
  • Hi, guys

    I'm a newbie Construct user (less than 8 months experience) and it's my first time with the Multiplayer in Construct 2, so be patient, please.

    I have read the whole tutorial for Multiplayer concepts, and I understood that the peer needs to send informations to the host in order for the game to work (like in Pong or Game example that comes with Construct).

    I just didn't understand how this can be done. In my capx (link attached at the end of this post), the game object in the peer side tries to move, but moves back instantly because no information was sent to the host.

    To be more specific, the game is turn-based. The attacker will choose an item from the menu, this item will move right to the front of the soldier, and then the turn will change to the defense player. But this is not happening, because the game objects are not moving and variables are not changing. The items from the peer side are not even showing on the menu. Modifications are being overridden by the game objects positions in the host screen, so the peer can't play at all, and can't see the changes mades from the host too.

    Can someone give me a little help with this? Thanks in advance, and sorry for any gramatical errors, english is not my native language. =)

    https://www.dropbox.com/s/zpamh273aeg8j8q/PrototipoRodrigo.capx?dl=0

    P.S: Already saved an test alias for debug, so you can go right to the game layout, the game will automatically connect to Scirra server.

  • Syncing only happens one way - from the host to the peer. Peers do not send synced object positions to the host. That means when you move an object on the peer side only, it will get corrected based on the host's object state. A peer should send their input to the host, and the host should move the proper object based on the peer's input. This will in turn get synced back to the peer if your object is synced.

    If you do any moving on the peer side, this is called local input prediction. This is to show responsive input for the sake of the peer visually, while the peer client is waiting for confirmation from the host during the latency period. As long as they are close, you will not notice any bouncing around of position. The host remains authoritative regarding position and synced variables.

  • Hey! Thanks for the answer!

    Now I don't know if the problem is in my capx or in the server. The game object seems to just bounce back and forth like it is with high latency or lost connection. So, should I abandon this multiplayer project?

  • Before testing it over a live connection, you should test locally on a single pc by opening multiple tabs/windows. Then you can confirm that it is not a latency issue.

    If it is still bouncing, like I said in my previous post, it is because you are trying moving the object on the peer side only and not the host.

    As for abandoning your project... I would guess that most people who try to use the multiplayer plugin are not properly prepared to do so. On the other hand, it is only by trying and sticking with it you can really understand how to use it, so it is up to you whether or not you are willing to spend the time and effort to learn.

  • Yes, it is still bouncing. I am testing locally atm. I already knew the object is moving only by the peer side, and the changes are being overwritten by the host, but still don't know how to sync both. Also, I'm using MoveTo plugin, and the objects are not associated with any players, I don't know if this helps.

    About abandon it, I said this because I need to send to my teacher on Monday as my college task. I'm trying to export for mobile too (part of the task), so there's really no problem if the computer multiplayer works or not, it's a bonus. I was just curious about multiplayer in Construct 2, then I decided to learn it. =P

    Thanks for your time, though!

  • As I mentioned in my first post, to sync you must have the host move the object. The peer sends his inputs to the host, and the host will move the object for both the host and peers.

    Before attempting multiplayer, I always recommend going through and actually doing all four official multiplayer tutorials and truly understanding them - trying to figure it out on your own is mostly impossible.

    That said, I would not recommend trying to include multiplayer for a project that is to be turned in on Monday

  • Yes, indeed. I will keep trying to get it to work with this in mind a couple of times this night. Otherwise, I'll just disable the multiplayer group.

    I read the tutorials, but I sure missed something. I'll re-read now more carefully.

    Thank you! =D

  • Excuse me. I have same problem "peer always follow host".

    do you have any advice?

    oosyrag

    Lucatiel641

  • Read, follow and recreate all the multiplayer example tutorials, starting with construct.net/en/tutorials/multiplayer-tutorial-1-concepts-579.

    Make sure the host is the one moving and handling sprite object positions while the peer is only sending inputs to the host.

    If you want to utilize local input prediction, make sure the movement events on the peer and host match.

    Then if you still are stuck, provide more details, and post a minimal example project with the issue you are having so that you can get better advice.

  • oosyrag Thank you. I will try again

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I would really advice you to use the photon plugin instead of the official one. It is so much easier to understand and to use.

    A big advantage of it is, that it is not peer to peer, and your projects can have up to 20 players at once without paying.

    You sync data between both players, which is much better to manage in my opinion, since you don't have to make up 2 separate versions for the host and the peer.

  • Thank you for the advice mr 13spongg13. Are only 20 players? I want 100 players.

    I will try this photon plugin

  • Pras

    Do you have any online game already? It's hard enough to get to 5 people playing, how are you expecting 100 concurrent players? (obviously only if you don't have a large community yet)

    The limit of 20 is for the free version, you can pay 100$ once to have a limit of 100 players. The tiers above that are on a monthly subscription model.

    The free version will TOTALLY do the job if you don't have a huge community yet, reaching over 100 will probably only serve if your game is seriously popular.

  • Thank you for the advice Mr 13spongg13. very helpful

  • Excuse me mr 13spongg13 I don't understand how multiplayer photons work, how they send data. do you have any suggestions bro, like the tutorial link that explains the concept of photon.

    Thank You

    Pras

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