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

Get help using Construct 2

Post » Thu Sep 29, 2016 12:41 am

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.
B
13
S
6
Posts: 9
Reputation: 1,093

Post » Thu Sep 29, 2016 2:09 am

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.
Mistakes were made.
B
53
S
26
G
114
Posts: 1,695
Reputation: 64,338

Post » Thu Sep 29, 2016 3:26 am

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?
B
13
S
6
Posts: 9
Reputation: 1,093

Post » Thu Sep 29, 2016 4:00 am

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.
Mistakes were made.
B
53
S
26
G
114
Posts: 1,695
Reputation: 64,338

Post » Thu Sep 29, 2016 4:11 am

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!
B
13
S
6
Posts: 9
Reputation: 1,093

Post » Thu Sep 29, 2016 4:16 am

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 ;)
Mistakes were made.
B
53
S
26
G
114
Posts: 1,695
Reputation: 64,338

Post » Thu Sep 29, 2016 4:22 am

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
B
13
S
6
Posts: 9
Reputation: 1,093


Return to How do I....?

Who is online

Users browsing this forum: SnipG and 10 guests