What makes hit detections laggy on server?

I’ve been working on a combat system for a few days recently and I’m just confused to why when I do checks such as .touched, raycasting, region3 & magnitude they never actually hit when the player is at a high speed (running or even walking sometimes)

Is there anyway to resolve this or is there a reason to why this happens? I have no code to show because I’m just wondering but if you want to review let me know.

Yeah that happens because of ping, you can’t do anything about it really. You could do client-sided hitboxes which would be very smooth and fluid, but remember that exploiters can take advantage of them if you don’t implement proper safety measures.

It’s not necessarily lag/ping but rather processing time. The server is incapable of processing physics at a high framerate (speed) like clients individually can based on their device specifications. The update rate of physics for the server is significantly slower by nature.

Generally you should not be doing hit detection on the server for this reason. Hit detection is best done by the client which then requests the server to perform an action. The server’s job should be to validate that the hit was legal and then apply the action accordingly.

There are some who will argue that doing it from the server is “secure” but the character’s physics are calculated by the client anyhow so there’s still some client authority when the server is the one calculating hits, so best shift it to the client to begin with. The server’s really only designed to work in non-computationally expensive pure-data operations for the most part.

5 Likes

its on server and server always has a delay bla bla

never make them on the client though!!