I have a kinematic rigidbody (let's call it A for simplicity) controlled via transform and a regular rigidbody (lets call it B) controlled by physics. A hinge joint is attached to B, and A is specified as connected body. The obvious intention is as A moves (sometimes in a very abrupt manner) B should follow it. At the same time, B's rotation is unrestricted, hopefully creating a "ball and chain" effect. So it does, but the distance between A and B's anchor seems to be somewhat arbitrary. Sometimes B flies real far away from A, sometimes it gets pretty close. I tried it with and without a spring with more or less the same effect. Is there any way to control the distance to connected body ?
It depends on the strength of the spring. A higher strength results in a smaller distance from A to B. However, the distance which A is moved affects the "recoil" of B. For example, if you move A ten units away from B and the strength of the spring is 1, then B will fly towards A with a velocity of 5, decreasing until B reaches A. Momentum will push B past A 3 meters.
However, if A moves 30 units, then B will fly towards A with a velocity of 15 units/second. It will be pushed past A 10 units, thus resulting in the larger distance you described.
There's really no way to fix this, as it is resultant of Unity's physics system. You'll have to try a different method. Have a look at the camera follow script packaged with Unity if you're looking for a smooth follow system.
Please note that the values given are relative to each other only and do not reflect real values within Unity