Projectile Weapons Server Sanity Checks

What are some effective solutions to verifying client side hit detection on the server?

You could,

  1. check the proximity of the objects,
  2. if the game has a lobby, you could check if the player who initiated the hit is participating,
  3. and you could check if the object can see the other object using ray casting.

All valid, depending on your requirements.

1 Like

How could I handle potential false positives with the third suggestion?

As in, due to lag and player movement etc the players positions on the server is such that they are now obscured by an object.

It’s a compromise. You can either be more strict, at the cost of the hit not counting, or you can be less strict to account for lag.
What exactly is the hit being used for?

1 Like

The hit is bullet damage.

A possible solution to this false positive is for the client to send the ray’s start position to the server along with the hit position, and then the server draws a new ray from the characters current position to see if the shot is possible, then you compare the two positions and see if the distance between the (clients original position before the lag) and the (server-checked characters current position). If the difference is above the margin of error, or at too great an angle from the previous position then you can kick the player. Perhaps you could make this more accurate by basing the margin of error on the player’s ping or something, I don’t really know.

1 Like

I don’t think that kicking players is a good idea, it can lead to a bad experience. I think disregarding the shot would be a better solution, as players with poor internet connection may make false positives.

Yes, I see your point, kicking them is a bit harsh lol

But, as for false positives, this:

would probably help to reduce them a lot.