I spent the last week working on the actual networking part of my engine. I decided on going with a “server controls all” approach. Any instance-able class type in my engine will be automatically replicated from server to client when created, updated, or destroyed. So if I create a folder on the server, and name it “Jeff”, a folder with that same name will appear in the same place on all clients. This level of replication made it convenient to have the server control all main game features.
Then I extended it into Physics. When a physics object exists within a game object, and it is currently NOT sleeping, it will send updates to all of the clients, expressing where it is and where it’s going. This forces all physics simulations of the clients to be synchronized with the server.
I then took it a step further. Regarding the physics… If a physics object exists as a descendant of a players character, the server will not tell THAT PLAYER that his physics is updating. Additionally, any update that THAT PLAYER sends to the server regarding that physics object will be accepted into the server. i.e. your own client can have control of your own players physics, and the server will accept it. This allows me to have players locally controlled and still update to the server, and have OTHER clients see those changes. You can’t, however, from your own client update some other players physics, as it will get rejected by the server. Finally, if you manually set the position of a client-controlled physics object on the server, that will still force replicate to the client. This allows me to still create some sort of “anticheat” on the server, where I can prevent players from walking through walls locally (using server-sided raycasting & teleporting).
Then I decided to make a ping-pong game to show it:
Your paddle (red) is simulated on your client. Your position is sent to the server and the server accepts it. The ball is completely server sided, and will only collide with objects on the server; Same with the server’s paddle (green).