I’m making a gun system with raycasting.
Im handling the raycast be on the client,
But how does the server handle it without people being able to cheat it.
I want it to be responsive but also not easy to exploit. What’s the best way to handle this?
I’m making a gun system with raycasting.
Im handling the raycast be on the client,
But how does the server handle it without people being able to cheat it.
I want it to be responsive but also not easy to exploit. What’s the best way to handle this?
You could let the server know which part the client hit and then raycast towards its position on the server, and if the server side raycast doesn’t hit the same part as the client, don’t apply the damage (still show visual damage indicators and that player being hit on the client, for immediate feedback), although if you use the character’s position on the server when doing the raycast, if the player were to do a really quick peek the bullet could hit the wall instead because theres always a delay between the server receiving the client’s latest position due to ping, which could eliminate peeker’s advantage but in return could make it frustrating for the player whos peeking as explained in the scenario I listed above. You could also trust the client and let it pass a position that it wants the server to raycast from, and if the hit positions of the both client and server are close enough, apply the damage. But then you have to remember that the client can make the server raycast from anywhere, so it all really depends on how much security ur willing to sacrifice for accuracy. And how your game is structured.
Raycast on a client.
Send hit position (3 f32, preferably inside a buffer so 12 bytes inside a buffer) to the server.
Based on that, calculate a .Unit (CharPosition-RecivedPos).Unit and do raycasting on the server next.
This ensures info will catch up, and you don’t end up shooting things you’re not meant to while walking; it will auto-adjust where you want to shoot.