I want to make ability/skill projectile system, but if I let the server to handle visual effects, I’m afraid that It will be laggy for laggy players… So I decided to let the clients handle the visual effects while the server does verifications to prevent exploiters.
This is the steps:
- Client tells the server that the player is using an ability.
- Server every client to create its visual effects.
- When the projectile hits someone in a client, the client will send “onHit” event to server. (Intendedly, every client will send same “onHit” event.)
- After getting an “onHit” event from a client, the server will check if it the “onHit” event is possible to happen using raycast from projectile’s origin to target direction. If the ray hit specific player (based on data the clients gave), then damage the player and don’t accept any same “onHit” event from different client. But, if the ray doesn’t hit that player, don’t do anything (wait until other clients fires “onHit” event that is possible).
But there’s one problem, if the ray is blocked by other person who weren’t there when the projectile passes their position, then the player who are supposed to be hit won’t be detected. This is the visualization of the problem:
My solution is to simulate hitbox of the projectile from server, but simulating on server, especially if there are many projectiles will give too much weight for the server to handle, how do I verify that it is possible to hit player using the ability/skill without giving that much weight to the server?