rotate spring joint locally

I have a spring joint attached to a rigidbody that is driven by kinematics. Everything works fine, until the Connected body starts to rotate in world space, and the spings orients remain the same, resulting is a “folding” of the object.

Is there a way that I can transfer the world rotation values of the Connected body into the spring joint so that the two objects are always sharing the same x y z rotate values?

Hello,

This does seem like a bug in the engine, but it’s hard to know for sure. (For example, what if you wanted the spring joint to represent something like a kite on a string? Would you really want the kite to rotate when the string rotates?)

At any rate, this code seems to achieve the desired effect of getting an object with a spring joint to rotate with its parent:

using UnityEngine;
using System.Collections;

public class ParentSpringJointRotation : MonoBehaviour
{
	SpringJoint MyJoint;
	Quaternion OriginalRotation;
	Quaternion InverseParentRotation;

	// Initialization
	void Start ()
	{
		// Grab the spring joint
		MyJoint = gameObject.GetComponent<SpringJoint>();
		
		// Get the original joint rotation
		OriginalRotation = MyJoint.transform.rotation;
		
		// Get the inverse of the parent rotation
		InverseParentRotation = Quaternion.Inverse(MyJoint.connectedBody.transform.rotation);
	}
	
	// Update is called once per frame
	void Update ()
	{
		// Calculate the rotation delta of the parent
		Quaternion ParentDeltaRotation = (MyJoint.connectedBody.transform.rotation * InverseParentRotation);
		
		// Multiply the delta of the parent rotation by the original joint rotation
		MyJoint.transform.rotation = (ParentDeltaRotation * OriginalRotation);
	}
}