Hey guys. I’m creating a multiplayer FPS game using Colyseus as the server and I have the following dilemma:
When the player clicks the left mouse button it executes the shoot function and within that function the raycast will be executed and then the client sends the raycast result to the server to be shared with the other players that are in the room.
I would like to know if it is possible to run the raycast on the server side.
My goal is to remove from the client the responsibility of executing the raycast and assigning it to the server, thus preventing any malicious player from sending false results.
That’s good thinking in adding anti-cheating to your game, and yes that’s the proposed way to do that.
Of course it’s not an easy task, you will have to an instance of your game in the server, usually it’s a headless instance (no need to render anything, just run the same world/simulation in parallel).
After you do that, you can send the user requested action and execute the raycast on the server. You can still execute it on the client at the same time so the player doesn’t show any lag, but the actual result networked to everyone would be coming from the server.
Very interesting. I’m studying more about it. Many thanks for the reply