Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
2D distance constraint

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 rigidbody's 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 doesn't take into account mass/force or any fixtures. You can see here I want movement on the X/Y and rotation only on Z.

Help?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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]

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!