#Ideas for server side hit detection with lag compensation

1 messages · Page 1 of 1 (latest)

kind harbor
#

I'm using a modified version of the task scheduler from the tower defense video to make a FPS game. There are two ways I can go about doing hit detection:

Client side: The client raycasts and sends the raycast result to the server
Server side: The server uses the client's camera rotation and the position of the character and does hit detection server side

The issue I'm having is that client side is easily exploited and server side is very inaccurate as there really is no way to have accurate lag compensation. I want to try using the task scheduler to create "snapshots" of the game similar to how Valve does it and use that to rewind to the tick that the client fired at but I have no idea how to go about doing this.
Here is an article about how Valve handles this, there was a better one but I can't find it anywhere: https://developer.valvesoftware.com/wiki/Lag_Compensation

Valve only stores up to one full second of snapshots before erasing them from memory. I am unsure how to go about storing these snapshots in an efficient way. Here are some of my ideas:

  1. Use a Linked/Hybrid List and have a cap on the amount of entries. Once the cap is met, remove the last entry and enter the first entry.
  2. Have an array indexed by the tick. Ex: Snapshots[tickNumber] = snapshot
  3. Just use client sided hit detection

The snapshots only include player positions, however I am unsure how to go about creating these snapshots and what to put in it. Would I need to manually go in and write down the CFrame of each and every limb on the character? I feel like this would exponentially use up a lot of valuable server memory but I'm not sure. If there are 50 players in a server (extreme example), 32 ticks per second, and up to one second of snapshots, that's 32 snapshots for 50 players for 6 limbs. 32 * 50 * 6 = 9600 separate CFrames stored in a Linked/Hybrid list or an array. I feel like that would hog memory.

If anyone has any ideas or wants to discuss this let me hear it

kind harbor
#

I did some testing and having 9600 CFrames stored in an array barely even affected server memory, I'm going to go through with implementing this using an array and I'll update how it goes once I'm done in case anyone would like to try this for themselves

grave magnet
#

sounds very overkill, even very large roblox fps games such as phantom forces just make the server lenient on what is a valid shot and what is not instead of implementing robust snapshot systems

#

if your game is going to be very popular. people will find a way to aimbot it anyway no matter what kind of anticheat you have. even million dollar companies cant combat this. and if your game isn't going to be very popular, not many exploiters are going to care about it so its probably safe anyway

#

middle ground is having enough checks on server where someone cant just headshot everyone from anywhere

night geyser
#

Do this thing every 5 minutes or 10 minutes of gameplay then

#

Store the cframes asynchronously

kind harbor
kind harbor
night geyser
#

Is this to prevent aimbot exploiter like r0lfu said

kind harbor
#

No, I just wanted to make something interesting