Server Side bullet shooting

Here’s my thought process on how to go about doing this.

  • You need a reliable and accurate bullet simulation.
  • You don’t want it to be exploitable, so you can’t completely trust the client.
  • Can’t simply fire to server and simulate from there as it looks laggy, has input delay, etc.

What I suggest doing is this:

  1. When firing a bullet, simulate its trajectory on every client separately. To do this, you will need to fire the bullet on the client as well as fire to the server, then tell every client to simulate a bullet for that player who fired it simultaneously.
  2. When the bullet detects a hit on the client that fired it, validate that hit on the server through some sanity checks (i.e. check if it went through a wall, was too far away, was fired on a player that they shouldn’t have vision on, etc.) If it doesn’t pass the sanity check, then flag that player for a sus shot, and if they have lots of flags then kick them. (I don’t suggest banning as false positives always exist)

Of course, you’ll need to do some extra stuff to ensure the bullet hits don’t look wonky for other players (i.e. ghost hitboxes).

I suggest using FastCast for projectiles, by the way. They help a lot with modeling projectile bullets and handling hit detection.

4 Likes