How do I apply lag compensation for projectiles?

Get help using Construct 2

Post » Wed May 04, 2016 4:01 am

Specifically, are there any techniques/best practices anyone can share for creating/destroying synced objects for multiplayer?

I understand lag compensation for already created objects - When sending the input to the host, the peer will also move the object instantly, then the game engine will subtly and automatically correct the object's position/angle on the peer based on the authoritative host instance.

Especially with the 80ms simulated latency built in, projectiles appear in significantly offset locations when the movement of the player is compensated for and the creation of the projectile object is not.

A related matter is the destruction of objects - it takes a noticeable amount of time for a synced object that should be destroyed to disappear from a peer's viewpoint. I have ideas to fudge this with animations and opacity, but was wondering if there were better ways.

I thought about creating/destroying the object on the peer side ahead of time, but then the host would create a duplicate due to the syncing. Should I not sync the projectile object at all and create my own system for position compensation (host adjusting peer's objects) via messages? There is also the issue in my specific game where I'm applying a random angle variation on the projectiles for a cone of fire... The host and the peer would not get the same random numbers if they each did their own thing.
Mistakes were made.
B
52
S
26
G
108
Posts: 1,606
Reputation: 61,133

Post » Thu May 05, 2016 7:14 pm

You have to use future position prediction.

Like this: https://developer.valvesoftware.com/wik ... timization

This helps frame the question: http://www.gabrielgambetta.com/fpm1.html
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,418
Reputation: 4,830

Post » Thu May 05, 2016 9:21 pm

Thanks gumshoe, those are some excellent articles. I'm mostly familiar with the concepts of authoritative hosts, interpolation, and lag compensation. Ashley's own multiplayer tutorials also cover the concepts and walks through lag compensation for instant hit weapons.

I'm a bit stuck regarding lag compensation for created objects in particular and working with the multiplayer plugin's object syncing system. If I were to create an object client side instantly upon receiving input to do so (similar to moving a player immediately client side upon input, then correcting position based on host version), the host would also create the object upon receiving the input and sync that object. The peer would then see two created objects instead of syncing the one that the peer already created...

I'm starting to think I might need to create a "bank" of already synced objects located somewhere off the layout, and just move them around as needed rather than trying to create and destroy them dynamically.

The other thing I'm thinking is to not sync the projectile objects at all and just have the peer display "phantom" objects as purely visual approximations.
Mistakes were made.
B
52
S
26
G
108
Posts: 1,606
Reputation: 61,133

Post » Thu May 05, 2016 10:32 pm

I found this - http://t-machine.org/index.php/2012/03/ ... etization/

Rotmg is a bullet hell type game in a MMO setting, with similar projectile mechanics to the kind I'm working with. They made some interesting decisions with the netcode that I don't know if I can duplicate in C2. Don't know if I want to either, as compromises must be made.

I'm going to research and see if I can find any good articles on Quake netcode, as many Quake weapons are projectile based and not hitscan. Also competitive pvp has different netcode requirements than an MMO, which would influence compromise decisions in different ways.
Mistakes were made.
B
52
S
26
G
108
Posts: 1,606
Reputation: 61,133

Post » Sat May 07, 2016 5:20 pm

You probably can replicate (JavaScript is extremely powerful), but you will likely have to use a custom server in addition to the C2 client. The problem with the Multiplayer plugin is that it is peer-to-peer, and the game that you are suggesting sounds like a more centralized type architecture may be required.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,418
Reputation: 4,830

Post » Wed Feb 22, 2017 4:10 am

Message: 12thmix can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
https://github.com/polpoy/colyseus-construct-plugin central nodejs server that works with the C2 client
B
15
S
7
Posts: 15
Reputation: 1,260


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, brunopalermo, Lancifer and 24 guests