Projectile Lag Compensation

So I have a projectile weapon and I’m trying to figure out how to detect hits with lag in mind. I’ve looked through other posts about lag compensation and this the system I have in mind:

  • For every .1 second, store a player’s Position and Velocity Magnitude on the Server and keep them stored for 1 second.
  • When the projectile on the client for the person who is using the tool touches a player, fire an event and give the server mouse, time, and projectile position.
  • Get the victim’s postion from the given time, create hitbox part in that position, create ray from player and mouse data.
  • If ray touches hitbox and the player’s distance from the hitbox is <= the magnitude then damage the victim.

Would this be a good method for a lag compensation system?

I’ve been thinking about this for a while myself actually shooter games fan and I think the way I would go about doing this would be on the server; every interval, store all the character’s part positions for every player and with the help of the player’s ping, roll back the server to compensate for the ping and compare the hit position which you get from the remote event (sent by the client) to all the character part positions in the character to see if the position sent by the client is within a certain amount of studs away from either of the positions, then deal damage. You might even want to add a raycast in there to check if there were any walls or objects between the player who fired the shot and the position they hit.

Lag compensation client-side isn’t really lag compensation. This is called client-side movement prediction which is a bit complicated to implement. But here’s a post about it.

I hope this helped.

2 Likes