Should raycasting be done on the client or server?

Hi, well the title says it all; should I send a raycast from the client (and then try to verify as much as possible on the server) or just detect input (position, mouseHit) and then do the raycast on the server?

For a casual “shooting” game (not like phantom forces etc.) should I raycast on the server or still on the client?

Also, the game will have around 10 players, so not many.

It’s quite close combat, the furthest wizard wand (I am making a wizard style game) goes around 500 studs. (the map is not larger than 500 studs in diameter…)

Thank you for answers!

5 Likes

For best player experience, client.
Raycasting on server will cause delay between the click and the fire, which will ruin the player’s experience.

3 Likes

Yeah, I guess that is the method that might be the most suitable.

As for verifying the results (on the server), what if statements and sanity checks should I do? (After recieving raycast results from the client)

Sadly, I don’t think you can do any verifications on the server other than ammo and RPM verifications, other verifications will just be too expensive for the server.

Thank you for your answers, I will look into that.

It is just unfortunate that server-side raycasts are expensive. While client-side raycasts provide good user experience, they subject your game to exploiters. Server-side raycasts provide bad user experience while making it impossible for an exploiter to shoot through walls.

6 Likes

raycasting on the client would be faster, but at the cost of security because an exploiter can easily play with the raycast.

1 Like

Do both use Server events but listen if you do it to the way where the server makes parts in a folder and the client visulaizes those parts and the server can check the positon of the servers line of the raycast and the clients line of the raycast if the line is different than the server can ban clients for hacking as the inital raycast should be the same as the client ray cast

3 Likes

Wouldn’t it hit in different places every time? As the raycast on the server side will only be created a few split seconds later and if the character is moving or the mouse is moving then the position will be different.

i expressed that being a issue hence the different ray positions

So I guess the only way around this would be to leave some leeway?

Yes sir!

(lorem ipsum lorem lorem bysum )

i dont understand it well can u please explain ?

Hey so basically what i was trying to explain is
Raycasting on both the client and server side to prevent cheating And also measure the lag from the server to add some exception as the server and client raycasts will always be somewhat different so adding some leeway or space for error helps to not kick innocent players. Hope this helps

1 Like

well but i thibk that there would be an offset to it right?

Yeah that is what i had explained