Should i raycast on client or server?

So like the topic says, will it be a overall better experience if i raycast on server or client?

I’ve been quite anxious about it. Are there any differences and what should i do to get maximum efficiency.

Depends what its for. Most of the time its better to do it on the client. If you are doing occasional raycasts on the server, you should be fine. Basically, if what you are raycasting is for the client, do it on the client. If its something that is for multiple people, etc. Then you can do it on the server (or just have both those client make their own casts.) I mostly steer away from raycasting on the server just for possible performance issues.

2 Likes

The same as above: if it is an event for the player (firing a gun for example), it should go on the client but the server should confirm the data.

This is also why it is difficult to prevent an aimbot, beacause an exploit can eliminate the client’s “defenses”

1 Like