Ray casting on Client instead of Server?

I’ve seen posts where people advise doing ray casts on the client to make the delay less while doing sanity checks on the server. Is that a good idea of going about it or is there a better method in your opinion? And if you agree with doing that, why, wouldn’t it cause delay issues or the player can constantly spam it without aiming?

I’ve usually been doing the casual raycast on the server and replicate effects to all clients, is that still a good idea of going about it?

However, if I were to be doing raycasts on the client, what should I be looking out for on the server?

1 Like

There’s nothing special about raycasts that makes them especially suited for being done on the server or client. It’s no different than adding two numbers.

What does matter is whether or not it’s critical for the gameplay. E.g. if it’s just for playing footstep sounds locally then it’s fine to do it on the client only. If it’s for checking line of sight for some gameplay mechanic that doesn’t have to be super responsive / low latency, do it on the server. If it’s something like hit detection for an FPS, do it on the client to make it feel instant and double check on the server to prevent cheating / dealing with latency.

3 Likes