How do I apply lag compensation for projectiles?

0 favourites
  • 6 posts
  • 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.

  • 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

  • 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.

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • github.com/polpoy/colyseus-construct-plugin central nodejs server that works with the C2 client

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