Collision and latency on a multiplayer coop-game (Should i fully trust the client ?)

The technique you’re looking for is called lag compensation. (Read that whole article for the full explanation of how this works in Source, and pretty much every other server-authoritative, engine.

Here is an example implementation in Unreal:

I also recommend checking out some courses on Udemy, there are multiple that I’ve watched which cover how to do lag compensation, such as this one:

Additionally, there’s a new plugin I saw on the marketplace that’s on sale right now, although I don’t think it does the client-side prediction part that’s necessary to complete the puzzle:

RANT: Of course, you can always just decide to trust the client and use an anticheat. Doing server-authoritative networking has a lot of overhead in performance and development time, and even with the tightest server-authoritative networking when it comes to hit detection, players could still aimbot, triggerbot, spinbot, etc, and essentially completely ruin the game for other players even though they are “technically” playing by the rules according to what the server is verifying, i.e. they are correctly sending the server data saying “I am aiming at this guy’s head right now” when they shoot with an aimbot for instance. You do probably want to go fully server-authoritative when it comes to any kind of in game economy or inventory system, but with hit detection, it is perhaps not worth fully implementing a crazy high tech system like Valorant or CS:GO has for lag compensation with client-side prediction, because it solves a very limited subset of problems when it comes to cheating, and a holistic approach to anti-cheat is necessary to really stop people from ruining gameplay in competitive settings. In your case, since it’s co-op, there’s probably nothing wrong with just trusting the client.

2 Likes