- Home /
Question by
ibrahim_aboelsuod · Jul 24, 2015 at 07:18 PM ·
hingejoint2d
How to set anchor position in hinge joint 2D?
I am trying to create a 2D chain in which every part is connected to the part above.
'startPoint' is the 1st part and 'newNode' is the second.
both has a hingejoint2D component and Rigidbody2D component.
here is how i try to connect them.
HJ=newNode.GetComponent<HingeJoint2D>();
HJ.connectedBody=startPoint.GetComponent<Rigidbody2D>();
HJ.connectedAnchor.Set(0,1);
HJ.anchor.Set(0,1);
the connectedBody changes to startPoint Rigidbody2D, but the connectedBody x and y stay at 0
why this is not working? and what is the correct way to change the anchor position?
Comment
Best Answer
Answer by ibrahim_aboelsuod · Jul 29, 2015 at 01:51 PM
it was a dumb mistake, this is what I ended up doing:
HJ.connectedAnchor=new Vector2(0,1f);