Multiplayer Physics interaction
Minimal description
I'm using a slightly modified NetworkTransform component. Each player has a set of cubes that they can move through the scene. Working together they stack and tip towers of cubes to kill bad guys. Players have authority over their own cubes.Problem
Tipping stacks of cubes all belonging to the same player works fine. Tipping stacks of cubes belonging to different players requires much more "effort". The torque applied to the bottom cube seems to die over the network, because the cubes above it are controlled by other players. It's still possible, but requires torque applied over a longer period of time.Are there any "simple" solutions to this sort of problem?
I've tried
- Setting SyncSpin to true on the NetworkTransforms.
- Applying the torque on each client. It seems the network transform somehow overwrites these updates.
- Setting Angular Velocity interpolation to 0 in the NetworkTransforms.
- Setting Rotation interpolation to 0 in the NetworkTransforms.
- A combination of all of the above.
Answer by tormentoarmagedoom · Jun 06, 2018 at 10:32 AM
Good day.
What i recommend is to dont make any client calculate any phisic. aEverything must be calculated by server.
I think best solution is to make the clients advise the server what they want to do, and its the server who calculates all interactions and phisics, and inform the position of all cubes to clients, so, all interactions will be calculated from the same computer, so there will be no "overwriting" from one cube to another.
Bye!
That sounds like a good suggestion. However, it would mean a serious restructuring of my game. So, I'm going to see if any simpler answers show up before I mark yours as correct.
Answer by myieye · Jun 06, 2018 at 11:37 AM
I'm able to get a pretty good improvement, by simply disabling the NetworkTransform on the other clients while it is being tipped/rotated.
Of course, the torque needs to be applied to the cube on each node in this case.
The effects are limited though. The amount of "lost torque" increases with the number of cubes in the stack. With 4 cubes, it's already quite difficult to tip the stack. Nonetheless, it's an improvement worth using in my case.