diff --git a/Assets/Mirror/Components/PredictedRigidbody/PredictionUtils.cs b/Assets/Mirror/Components/PredictedRigidbody/PredictionUtils.cs index efb73c980..7e75b8cac 100644 --- a/Assets/Mirror/Components/PredictedRigidbody/PredictionUtils.cs +++ b/Assets/Mirror/Components/PredictedRigidbody/PredictionUtils.cs @@ -326,8 +326,31 @@ public static void MoveSpringJoints(GameObject source, GameObject destination) SpringJoint[] sourceJoints = source.GetComponentsInChildren(); foreach (SpringJoint sourceJoint in sourceJoints) { - // TODO not supported yet - Debug.LogError($"Prediction: {source.name} has a SpringJoint on {sourceJoint.name}. Prediction does not support joints yet, this won't work properly."); + // copy the relative transform: + // if joint is on root, it returns destination root. + // if joint is on a child, it creates and returns a child on destination. + GameObject target = CopyRelativeTransform(source, sourceJoint.transform, destination); + SpringJoint jointCopy = target.AddComponent(); + // apply settings, in alphabetical order + jointCopy.anchor = sourceJoint.anchor; + jointCopy.autoConfigureConnectedAnchor = sourceJoint.autoConfigureConnectedAnchor; + jointCopy.axis = sourceJoint.axis; + jointCopy.breakForce = sourceJoint.breakForce; + jointCopy.breakTorque = sourceJoint.breakTorque; + jointCopy.connectedAnchor = sourceJoint.connectedAnchor; + jointCopy.connectedBody = sourceJoint.connectedBody; + jointCopy.connectedArticulationBody = sourceJoint.connectedArticulationBody; + jointCopy.connectedMassScale = sourceJoint.connectedMassScale; + jointCopy.damper = sourceJoint.damper; + jointCopy.enableCollision = sourceJoint.enableCollision; + jointCopy.enablePreprocessing = sourceJoint.enablePreprocessing; + jointCopy.massScale = sourceJoint.massScale; + jointCopy.maxDistance = sourceJoint.maxDistance; + jointCopy.minDistance = sourceJoint.minDistance; + jointCopy.spring = sourceJoint.spring; + jointCopy.tolerance = sourceJoint.tolerance; + + GameObject.Destroy(sourceJoint); } }