I have a vehicle with custom wheels which are connected to it by the HingeJoint components. Everything works perfectly when using this car in single-player mode. Wheels are actually as Cylinders. They have HingeJoints attached through which they are bound to the vehicle's Rigidbody. Then I set JointMotor.force and the wheels are getting rotated and the vehicle is moving. It all works very naturally in terms of physics, I don't need to emulate anything.

Still, there is an issue with network synchronization in multiplayer mode and I have no idea how to solve it.

It's said that the proper way to sync the position of a physical object is to use rigidbody.MovePosition(), but any manipulation with Rigidbody leads to the collapse of the vehicle hinge-joints. The only method that works is setting transform.position directly. But this is not recommended for physics and it doesn't allow to synchronize the vehicle smoothly with no twitching. Is there a way to solve this somehow?

I'm using Photon for networking (if it matters in the question context).

  • \$\begingroup\$ In case my explanation is not clear, you can see a similar approach in this free asset: assetstore.unity.com/packages/3d/vehicles/… \$\endgroup\$
    – Serg
    Jul 6, 2019 at 18:55
  • 1
    \$\begingroup\$ Have you considered deleting the hinge joints on the replica, and spinning the wheels visually based on the point velocity of its attachment point? That way you still get physics-based wheels on the master, and plausible rotation on the replica. \$\endgroup\$
    – DMGregory
    Jul 6, 2019 at 19:56
  • \$\begingroup\$ It's probably the only way. I'm thinking of sending the angular velocity of each individual wheel to avoid doing these calculations since I'm not sure I can do it accurate enough to look natural. \$\endgroup\$
    – Serg
    Jul 6, 2019 at 20:21


You must log in to answer this question.

Browse other questions tagged .