- Home /
Server runs physics, client only receives position data
I am working on a physics simulation tool prototype for use in my day job. I work in the automation industry and being able to test our automation software/designs in a virtual physical environment is very helpful. I have been able to get a working prototype that runs on a single machine but at high numbers of rigidbodies the framerate begins to drop. This is alright as the physics model remains up to date but makes the user experience less than ideal.
My thoughts are to make a server running all the physics simulations and controlling all positions etc of any objects in the scene, and clients which can view the scene. Clients would be able to move around freely to see the simulated system and interact with it in limited ways (clicking on machines to see their status, turning machines on and off) but the server would be authoritative and control behaviour of all objects and run all physics calculations.
My question is really if this is possible in Unity or not and how I could go about doing this? From research I have seen that physics in multiplayer games will vary between machines and must be corrected to a chosen master. Is it possible to make it so the server does the physics and the client doesn’t even bother with any calculations or behaviour except for example clicking on an object in the scene to bring up a menu from which the user can send a request to the server to alter some value or state of the machine in the simulation. The client would only receive positions and other display data for objects in the scene and render them for the user to view. The interactions from the user to the server do not have to be super responsive, in the order of one second of lag would be fine. My project will only ever be run over a LAN so bandwidth isn’t a main concern here. Also if this would require costly plugins it shouldn’t be an issue.
I hope to get my prototype to a point where I can show it to my boss, impress him, and be allowed to develop it properly during work hours. This started as a learning exercise for me so if unity isn’t the correct environment to do this sort of project in then at least I have learnt a lot.
Cheers
I'm not sure of the answer but I have a suggestion. You should consider client doing physics calculations as well as part of client prediction. Your server, of course, should have authority of where's what but unless your client simulates the physics you will get very choppy movement. Client-side prediction
Your answer
Follow this Question
Related Questions
I have a question for unity physics can simulate always same result with same input? 2 Answers
What would be the best approach to implement a conveyor belt? 0 Answers
Help with orbits 1 Answer
Simulating the graphics of a rolling 3D ball in a 2D game 2 Answers
Position synchronization problem in RPC Network System 0 Answers