Hello, the title says it all.
What I’ve tried:
-
Raycasting on server, has latency.
-
Raycasting on client, easily exploitable.
-
Using mouse target, easily exploitable.
What I was thinking I should try:
- FastCast? CFraming the bullet?
If you trust the input from the client for everything it sends you then yes, raycasting on the client is easily exploitable.
However, if you add in sanity checks, and do some confirmation checks on the server, you should be good. e.g.
- Player fires weapon and tells server it’s doing so and in what direction it’s firing from / the origin position of the bullet / the camera frame
- Server takes this package and puts it into an array and compares it to where it thinks the origin of the bullet should have been, and checks to see whether the direction it fired was in the FOV of the camera frame
- If there’s previous data, the server compares it’s previous packet data e.g. have they shot faster than the fire rate of the weapon? has the player’s position changed too much for the time that’s elapsed?
- The server then fires to all clients except the one that has shot to tell them to render the bullet
- If the client’s bullet hits a person, it pings the client to tell them they’ve shot someone
- The server finds the packet it initially sent that you saved to an array, and compares the direction/origin of the initial packet to the position the player hit their enemy - is there a valid start/end pos array (if not, they’re just firing the damage event)? Since we know the speed and maximum distance of the bullet, has the bullet travelled too far or too quickly? Is the bullet’s final position close to the enemy’s position? If we raycast on the server from the start position of the bullet, to the end position of the bullet, ignoring any dynamically moving objects, could the bullet have gotten to the point the client is saying it’s at (If not, then we know they’re cheating)?
- If it passes all of the above then we can be reasonably certain that it’s a legitimate shot, and we can damage / kill the enemy
This is assuming you’re performing multiple raycasts per bullet and incrementing their cframe along the ray path, if you’re doing a single ray this is even easier
4 Likes
Thanks for the reply, I’m actually looking for invisible rays(automatic weapon) and no bullet rendering so it might be easier.