Multiplayer - real-time game Example (Lag/Delay)

Get help using Construct 2

Post » Mon Jul 10, 2017 8:08 am

Why is there a noticeable delay on the client side when testing the game with 2 browser windows in the same PC? This can be seen when i aim and shoot at the host; the "PeerName" Text Object which contains the Health among other info takes a while to get updated on the client side, enough to be quite noticed (around 0.3 seconds, i'd say)
This feels even worst if you decide to spawn a projectile with Bullet Behavior instead of the "instant hit where you aim at" mechanic made in this example.
Why am i not getting a near zero lag/delay experience playing the game like this?
B
9
S
1
G
1
Posts: 4
Reputation: 935

Post » Sat Jul 22, 2017 3:26 pm

The bandwidth profile of the Multiplayer object is set to internet by default, which means it does not send updates as frequently as you are expecting, even though you are on the local PC.

Try using the Set bandwidth profile action ... to LAN. Keep in mind that if your game is intended for online internet play, you will need go back to Internet profile for that.
B
52
S
19
G
3
Posts: 21
Reputation: 4,502

Post » Fri Jul 28, 2017 2:47 am

There is no difference
B
9
S
1
G
1
Posts: 4
Reputation: 935

Post » Fri Jul 28, 2017 3:40 am

Lag is unavoidable. I think the reason you may see it locally is that the framework will run at similar update speeds when operating across a LAN or on the internet.

I am not sure what other suggestions might help you, but I can relate a similar issue I faced when there was too much lag while firing a projectile.

I found that sending a message to the server to "fire" instead of relying on input bits works out a bit faster. I am not sure if that will hold up on the internet, but at least locally it does. On client I send "fire" message, on server I use on "fire" event, find the player with the Multiplayer.FromId, and fire from that players location (additionally I do some validation that the player is able to actually fire at that time).
B
52
S
19
G
3
Posts: 21
Reputation: 4,502


Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 17 guests