public static HingeJoint CreateHingeJoint(this Joint joint, GameObject gameObject, Rigidbody parentRigidbody)
        {
            HingeJoint hingeJoint = gameObject.AddComponent <HingeJoint>();

            hingeJoint.connectedBody = parentRigidbody;

            // axis:
            hingeJoint.axis = (joint.axis != null) ? joint.axis.GetAxis() : joint.axis.GetDefaultAxis();

            // origin:
            hingeJoint.autoConfigureConnectedAnchor = false;
            hingeJoint.connectedAnchor = joint.GetConnectedAnchor();

            // spring, damper & position:
            if (joint.dynamics != null)
            {
                hingeJoint.spring = joint.dynamics.GetJointSpring();
            }

            // limits:
            if (joint.type == "revolute" && joint.limit != null)
            {
                hingeJoint.limits = joint.limit.GetJointLimits();

                // large joint limits:
                if (hingeJoint.limits.min < -180 || hingeJoint.limits.max > 180)
                {
                    JointLimitsManager jointLimitsManager = gameObject.AddComponent <JointLimitsManager>();
                    jointLimitsManager.LargeAngleLimitMin = hingeJoint.limits.min;
                    jointLimitsManager.LargeAngleLimitMax = hingeJoint.limits.max;
                    JointLimits jointLimits = hingeJoint.limits;
                    jointLimits.min   = -180;
                    jointLimits.max   = +180;
                    hingeJoint.limits = jointLimits;
                }
                else
                {
                    hingeJoint.useLimits = true;
                }
            }

            // data:
            JointUrdfDataManager.AddComponent(gameObject, joint.name, joint.type);

            return(hingeJoint);
        }
        public static ConfigurableJoint CreatePrismaticJoint(this Joint joint, GameObject gameObject, Rigidbody parentRigidbody)
        {
            ConfigurableJoint prismaticJoint = gameObject.AddComponent <ConfigurableJoint>();

            prismaticJoint.connectedBody = parentRigidbody;

            prismaticJoint.axis = (joint.axis != null) ? joint.axis.GetAxis() : joint.axis.GetDefaultAxis();

            // degrees of freedom:
            prismaticJoint.xMotion        = ConfigurableJointMotion.Limited;
            prismaticJoint.yMotion        = ConfigurableJointMotion.Locked;
            prismaticJoint.zMotion        = ConfigurableJointMotion.Locked;
            prismaticJoint.angularXMotion = ConfigurableJointMotion.Locked;
            prismaticJoint.angularYMotion = ConfigurableJointMotion.Locked;
            prismaticJoint.angularZMotion = ConfigurableJointMotion.Locked;

            // origin:
            prismaticJoint.autoConfigureConnectedAnchor = false;
            prismaticJoint.connectedAnchor = joint.GetConnectedAnchor();

            // spring, damper & max. force:
            if (joint.dynamics != null)
            {
                prismaticJoint.xDrive = joint.dynamics.GetJointDrive();
            }

            // limits:
            if (joint.limit != null)
            {
                prismaticJoint.lowAngularXLimit  = joint.limit.GetLowSoftJointLimit();
                prismaticJoint.highAngularXLimit = joint.limit.GetHighSoftJointLimit();

                // set linear limit
                prismaticJoint.linearLimit = joint.limit.GetLinearLimit();
            }

            // data:
            JointUrdfDataManager.AddComponent(gameObject, joint.name, joint.type);

            return(prismaticJoint);
        }