c# - 2D distance constraint -


i've been trying 2d distance joint working in unity. want free rotation both body joint , connected body, need mass , other constraints adhered to, such fixing rigidbody's position. i've tryed days now, no luck configuring joint type. tryed 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 doesn't take account mass/force or fixtures. can see here want movement on x/y , rotation on z.

help?

i know isn't answer, add comment button not there. i'm unity, have never used unity2d, , can't i've ever seen "moveposition" before.

you have better luck finding answer asking on http://answers.unity3d.com [again, apologize not being answer. i'd rather comment, tkat isn't option]


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -