Lag Compensation/Rewind Positions

I am trying to create a rewind hitbox system (based on the Valve networking model) that logs an object’s CFrame every tick so when a client fires a remote, the server. The issue is it doesn’t seem to be synced up entirely right.

The system works by storing the server time alongside the Part’s CFrame every tick in a table. When the client fires the remote, the synced server time is sent and used to calculate the travel time. From there, the server subtracts the receive time from the send time to get the ping and uses that to ‘look back’ in time to see where the object was.

The problem is that the rewind doesn’t seem to be properly lined up and I’m not sure what’s wrong (the red part should be overlapping with the green). They need to be near-perfect because the game I’m working on uses fast moving objects and it needs to validate the remotes properly.
I have attached the place below. Just line up your camera over the moving part and press “G” when it crosses over your mouse.

RewindPart.rbxl (51.3 KB)

If anyone has advice or a solution to this it would be much appreciated. It’s frustrating having to write server-side validation.

2 Likes

Don’t know if anyone answered you or if you ever figured it out, but if anyone is looking at this thread the answer is simple:

This diff

local diff = (serverTime-sentTime)

needs to be doubled to get the most accurate results.

local diff = (serverTime-sentTime) * 2

The reason is because server sided ping is half of what it should be

.5 seconds of simulated delay:
image

.05
image

0
image