<story><title>How to beat lag when developing a multiplayer RTS game</title><url>https://www.construct.net/en/blogs/ashleys-blog-2/rts-devlog-beat-lag-1607</url></story><parent_chain></parent_chain><comment><author>rcme</author><text>For an RTS game, you probably shouldn’t be sending unit positions over the network. Rather you should send events like “User A sent units X, Y, Z to position P at time T.” You can build your game as a simulation that plays back on both clients, so both clients compute the path of units X, Y, Z and locally play back the computer path. This allows you to perfectly recreate the state on both clients without needing to synchronize every single object. The best method of implementing this, that I know of, is called rollback net code.</text></comment>
<story><title>How to beat lag when developing a multiplayer RTS game</title><url>https://www.construct.net/en/blogs/ashleys-blog-2/rts-devlog-beat-lag-1607</url></story><parent_chain></parent_chain><comment><author>jmyeet</author><text>This is a surprisingly difficult problem. It&amp;#x27;s also what leads to a lot of cheats, dupes and hacks in online multipler games: you basically have to trust the client at some point.&lt;p&gt;The starting point for any such discussion is (as in this article) where all updates are done on the server. You then have to deal with packet loss and latency spikes but the real problem is subjective: it just doesn&amp;#x27;t &lt;i&gt;feel good&lt;/i&gt;.&lt;p&gt;Imagine you&amp;#x27;re playing Fortnite and when you pressed your trigger you had to wait 50ms for it to acknowledge that your gun fired. That bullet has travel time so there may be another update if you hit someone.&lt;p&gt;So instead the client gives you immediate feedback and proceeds as if that shot actually happened. This may well include calculating if you hit the target. That target&amp;#x27;s position may be interpolated too, not the location you last got an update for. This feels way more responsive.&lt;p&gt;What if your target actually stopped moving after you shot. You get into an ordering canondrum. Now imagine if shooting that shot had recoil (which could affect both aim and position) and getting hit moved the target (eg getting hit by an explosive of some kind).&lt;p&gt;Doing all of this when latency can easily be &amp;gt;100ms and having it feel good is incredibly difficult.</text></comment>