Is it possible to have client side hit detection for server created projectiles?

Hello!

To quickly explain, my current projectile system moves projectiles using cframes and does hit detection using raycasts on each frame. The server creates a projectile that is represented by a cframe value and does hit detection, fires a remote to every client and each client creates their own version of the projectile but with the actual instance and effects etc. The projectiles are in sync with a synced clock across the client and server. This system works really well for me, as the server handles when the projectile hits a player and does damage, while the client will do all the visual effects of the hit.

The problem is player positions are not perfectly in the same place on the server as they are for each client. For example, as each client controls their own player, walking forward will be instantaneous but the server will only see this walking a little later. So if a slow moving projectile is moving towards a player, the projectiles on the client and server are synced in terms of position, but if the player moves out of the way just in time, the server wont see this movement in time. This leads to a really big problem for me as the projectile wont show as destroyed but they will still take damage. Furthermore, a client can move into a projectile from the side and see the projectile on their client get destroyed, but the server sees this movement too late as it replicates and will not register any hit detection, leading to an invisible projectile still moving forward.

Not a very quick explanation, sorry! I wanted to avoid any sort of client side detection as if I have a moving wall for example, and all my projectiles are slow moving, it would be hard to detect if that hit detection was valid on the server as if I cast a ray it will hit the wall.

But this problem with player positions not being in the same place feels worse (even for players not lagging and with really low ping its really obviously not in sync), so I want to have clients verify each projectile hit. Then I’m at another problem where the server is creating projectiles, so which client is verifying the hit? I cant have the client getting hit verify it as that’s really exploitable, and if I have other clients verify it I have the same problem; other clients are like the server in the sense that they wont see the player’s movements instantaneously.

Even after researching lag compensation it talks mostly from what I’ve read about storing positions to turn back the clock, but wouldn’t I need the server to go into the future to see where a player is going to move before their movement has even replicated? Impossible surely?

Pretty much I want to sort out this problem with player positions not being in sync. My projectiles are all equation based so it’s really easy to use a time they were created and the synced clock to have them in the correct position, and everything goes well if the player isn’t moving. But as soon as they start dodging just in time, I have this problem. Is there any solution to this?

Thank you

if possible could you provide a GIF of this problem being serious, I don’t think this would become a major issue till your averaging concurrent 400 ping, and this is more of a Internet issue, theirs nothing you can do about this as regardless the server will have to in some way handle this since you would want all clients to see whats happening and having client sided hit detection as you said is extremely unreliable as the exploiter can simply just manipulate any data. From my personal experience with projectiles I haven’t seen any issues regarding it hitting me If i move a second later (when visually it didnt hit me). This is most likely something that will only effect people with very high ping (200-300+) If you still don’t manage to find a resolution then I would just tick this box to make sure players are getting sent to servers that are the closest to them (which would provide the best game play experience as you would be getting low-ping) image Sorry that i can’t think of any SOLID resolution to your issue.

1 Like

Whoa really long post, tbh not going to read all of it.

Heres my thoughts on the central issue though.

So the issue is all within the client, they dodge but there is a delay. But what if they were able to predict the projectiles motion ahead of time and dodge earlier in order to account for the delay?

The pros of this method should be that its still server side we are just tricking the client by showing them the future state on the server which should be possible.

1 Like