Been scrolling around the devforum and people wanting to do server-side hitreg and had a decently successful crack at it. I’m using Valve’s definition lag compensation to achieve this: Lag Compensation - Valve Developer Community
How it works (mildly simplified)
- Server stores everyone’s positions for the past second, 60 times a second (because that’s how fast heartbeat runs), using a circular queue.
- Player sends information on direction of ray and time they shot the ray.
- Server calculates player ping based on time (:GetTimeNow() - time).
- Use math.ceil() and math.floor() to lerp the hitbox on the previous “tick” and the next “tick”. ← have tested with and without this and it does improve hitreg while jumping significantly.
- Does hit checks that can be easily done with workspace:Raycast().
Here’s a short video of it in action:
Notice how it is a lot more unreliable when jumping. When the player isn’t jumping, the “missed” hits are usually very, very near misses (they should count - but are incredibly close - which I’m fine with).
Additional reading which I really got me going:
I’m wondering if there is anything I can do to improve the reliability, if at all.
Note: this was in #help-and-feedback:scripting-support, but I moved it here because, well it is a creation and I need feedback on it.