- Home /
Hinge Joints, distance to connected body
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 ?
Answer by e-bonneville · Mar 14, 2011 at 07:35 PM
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
Thanks for your answer Elliot. Do you think a different joint type will work better, configurable joint or spring joint maybe ?
Sadly, no, as all of Unity's joints behave the same way. If you want B to follow A smoothly, you'll have to look into writing your own system.
Your answer
Follow this Question
Related Questions
Hinge Joint? Unconstrained. 1 Answer
Why are my hinge joints inaccurate? 1 Answer
Truck-Trailer Hinge Joint 0 Answers
Configurable Joint just falls apart? 1 Answer
Configure configurableJoint to act as the disctontinued driveJoint 0 Answers