Take the 2-minute tour ×

I've been trying everything to get a 2D distance joint working in unity. I want free rotation to both the body with the joint and the connected body, I also need mass and other constraints adhered to, such as fixing a rigidbodys position. I've tryed for days now, no luck configuring any joint type. Tryed a verlet constraint using:

float xDistance = hinge.transform.position.x  - target.transform.position.x;
        float yDistance = hinge.transform.position.y  - target.transform.position.y;
        float newdistance = Mathf.Sqrt( xDistance * xDistance + yDistance * yDistance );
        float con = ( newdistance - maxDistance) / newdistance;
        Vector3 moveTarget = new Vector3( xDistance * 0.5f * con , yDistance * 0.5f * con, 0.0f );
        hinge.rigidbody.MovePosition( hinge.transform.position - moveTarget );
        target.rigidbody.MovePosition( target.transform.position + moveTarget );

But this doesnt take into account mass/force or any fixtures. You can see here I want movement on the X/Y and rotation only on Z.


share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I know this isn't really an answer, but the add comment button is not there. I'm good with Unity, but I have never used Unity2D, and I can't say I've ever seen "MovePosition" before.

You would have better luck with finding an answer by asking this on http://answers.unity3d.com [Again, I apologize for this not being an answer. I'd rather this be a comment, but tkat isn't an option]

share|improve this answer
Thankyou for marking as an answer :) I'm sorry I couldn't help more :( –  Georges Oates Larsen Feb 26 '11 at 19:53
add comment

Your Answer


