Some multiplayer questions - could someone please educate?

Discussion and feedback on Construct 2

Post » Mon Oct 13, 2014 10:53 pm

kmsravindra wrote:1. Which method out of the below is preferred to propagate data from peer to host in multiplayer and in what conditions each of them is used ?

A. Set Client input state "<variable>" to something and then use Multiplayer.PeerState (Associatedobject.peerid", "<variable>") sequence

Use that for anything latency-sensitive, which is generally the buttons the peer is pressing, i.e. as the name suggests, input states.

B. Send message with peer data within the message

Anything not latency sensitive, like chat messages.

C. Use Sync variable

Not an option, because that *only* sends data from the host to the peer. 'Sync' never sends anything from the peer to the host.

[re: is read for input] For me the confusion is whether this condition should be checked by host or by a peer?

By the peer, because only peers send their input. The condition is very simple. Imagine setting a global variable to true when 'On client update' triggers. The condition just checks if the global has been set. If you allow the player to move before then, it will simply cause an input prediction error, because the host is not yet aware of your movement. It's pretty minor though - even if an input prediction error occurs, it will be corrected a few moments later.

Another confusion is for the "on client update", this is a trigger, but what triggers it?

It fires 30 times a second to test the inputs, because that's how often messages are sent to the host (not 60, because that would use double bandwidth for little benefit). The frequency should not be important though. The trigger basically means "time to check what the inputs are, because it's about to be sent to the host".
Scirra Founder
B
403
S
238
G
89
Posts: 24,660
Reputation: 196,167

Post » Tue Oct 14, 2014 3:24 am

Thank you very much @Ashley. This clarifies lot of things
For game development / IT services contact - [email protected]

List of published iOS apps -
https://itunes.apple.com/us/artist/ravi ... d693234511
B
84
S
20
G
3
Posts: 337
Reputation: 7,368

Post » Tue Oct 14, 2014 4:03 am

Ashley wrote:It's pretty minor though - even if an input prediction error occurs, it will be corrected a few moments later.

Ah good to know this, so the conclusion is this will see some use for fast paced games like racing. That's why it is a bit difficult to make test case, simply because the error is quite unnoticeable visually. Is the input prediction error logged into the browser console? I don't remember seeing any error with regard to it.

Ashley wrote:It fires 30 times a second to test the inputs, because that's how often messages are sent to the host (not 60, because that would use double bandwidth for little benefit). The frequency should not be important though. The trigger basically means "time to check what the inputs are, because it's about to be sent to the host".

Is this frame rate dependent and is it correct if I assume it fires every other tick? I wonder what will happen if one of the peer have a significantly slower device compared to others..
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Tue Oct 14, 2014 7:48 am

DuckfaceNinja wrote:Is this frame rate dependent and is it correct if I assume it fires every other tick? I wonder what will happen if one of the peer have a significantly slower device compared to others..


i) That is my interpretation.
ii) Lag

And...

THANK YOU SO MUCH, ashley, that makes much more sense... really appreciate the clarification.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,728

Post » Tue Oct 14, 2014 11:32 am

DuckfaceNinja wrote:Is the input prediction error logged into the browser console?

No, because there is always input prediction error, it's just usually small enough to be unnoticeable. You can spot a serious input prediction error though by seeing if your player suddenly jumps somewhere else without you controlling it!

Is this frame rate dependent and is it correct if I assume it fires every other tick? I wonder what will happen if one of the peer have a significantly slower device compared to others..

It's intended to fire every other tick, but it is not framerate dependent (very few C2 features are). If your framerate drops to 30 it will send input every tick (which is the same frequency as every other tick at 60 FPS), and if it drops further below then input is simply sent less often. However the multiplayer engine is inherently designed to deal with missing data due to packet loss so this won't adversely affect the control, it will just make it a bit less accurate. The bigger problem is that the game is slow!
Scirra Founder
B
403
S
238
G
89
Posts: 24,660
Reputation: 196,167

Post » Tue Oct 14, 2014 11:39 am

DuckfaceNinja wrote:
Ashley wrote:It fires 30 times a second to test the inputs, because that's how often messages are sent to the host (not 60, because that would use double bandwidth for little benefit). The frequency should not be important though. The trigger basically means "time to check what the inputs are, because it's about to be sent to the host".

Is this frame rate dependent and is it correct if I assume it fires every other tick? I wonder what will happen if one of the peer have a significantly slower device compared to others..


As a sidenote, I think (well I saw, and that would just be logical..) triggers event are designed to work outside the normal event reading state, they can happen anytime, not just during tick normal checks of the entire event sheet, it is like events are verified every tick, but triggers just happen.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
22
G
18
Posts: 2,123
Reputation: 17,150

Post » Tue Oct 14, 2014 1:52 pm

Does anyone know how do I make drag-drop behavior on sprite work in multiplayer...Having this behavior on sprite doesnt have any influence as a Peer...Only on host it moves...Is it that I can move on peer side only using client input state variables / sync approach..? Behaviors on objects are not sync'ed?

Edit - I guess this is the answer from manual - It is important to disable any behaviors and deactivate any events on the peers that may attempt to move the objects themselves; this will conflict with what Sync object is trying to do, and will not have any effect on the host.

So does this mean any behavior that alters the positions doesnt work on peer? Because Pong example uses Solid behavior and it works both on peer and host...could someone clarify?
For game development / IT services contact - [email protected]

List of published iOS apps -
https://itunes.apple.com/us/artist/ravi ... d693234511
B
84
S
20
G
3
Posts: 337
Reputation: 7,368

Post » Tue Oct 14, 2014 3:28 pm

Ashley wrote:
DuckfaceNinja wrote:Is the input prediction error logged into the browser console?

No, because there is always input prediction error, it's just usually small enough to be unnoticeable. You can spot a serious input prediction error though by seeing if your player suddenly jumps somewhere else without you controlling it!

Is this frame rate dependent and is it correct if I assume it fires every other tick? I wonder what will happen if one of the peer have a significantly slower device compared to others..

It's intended to fire every other tick, but it is not framerate dependent (very few C2 features are). If your framerate drops to 30 it will send input every tick (which is the same frequency as every other tick at 60 FPS), and if it drops further below then input is simply sent less often. However the multiplayer engine is inherently designed to deal with missing data due to packet loss so this won't adversely affect the control, it will just make it a bit less accurate. The bigger problem is that the game is slow!

Great! Thanks for the info!
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Tue Oct 14, 2014 4:37 pm

@kmsravindra - the client input state is the only low-latency way of telling the host what you are doing. So it sounds like you want to set the object's x and y position as the client input values. Then it will move on the host. The peer will see it with lag, so you can simply display it at the mouse position instead of syncing to hide the lag.
Scirra Founder
B
403
S
238
G
89
Posts: 24,660
Reputation: 196,167

Post » Wed Oct 15, 2014 7:24 am

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?
For game development / IT services contact - [email protected]

List of published iOS apps -
https://itunes.apple.com/us/artist/ravi ... d693234511
B
84
S
20
G
3
Posts: 337
Reputation: 7,368

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 11 guests