Problem
Hi. I’m encountering an issue where projectiles look like they hit on a client, but the server’s model [or hitbox] does not align, so the hit does not process. Below is some footage that shows both a client’s render of a projectile and the server’s.
The green hitbox is the server hitbox.
The red is the client hitbox.
i.gyazo.com/d3088817332dae53652bb184f6f65869
Within the video, one of my arrows doesn’t register due to latency at 00:04. At 00:06, you can see ‘Scripted_Noah’ also encounters a no reg.
My Code
In an effort to make more sense of my code, I am excluding all sanity checks (which are used to defend against exploiters and are very light on performance [simple conditional statements, etc.]).
On the client, I record the input time of an attack using workspace:GetServerTimeNow(), ‘which returns the epoch time on the server with microsecond precision’.
Then, I send the client’s request over to the server and calculate the time it took to receive the input with this:
local receive_time = workspace:GetServerTimeNow()
local latency = receive_time - send_time
After that, in a nutshell, I plug the latency time into a function to match the client’s projectile position on the server.
Example:
f(x) = 2x
f(latency) = 2(latency) – this position should be pretty close [if not the same] to a client’s projectile position
Final Thoughts
Regardless of anything I’ve tried, I can’t seem to get past this ‘no reg’ problem. I want combat to be as fluid as possible, considering my game is mainly fighting-based. In my opinion, no regs are completely unacceptable and not something I want to overlook.