Access Joint

My two objects connected with fixed joint.
On key press I want to detach these tow objects
or vice versa.
How can I do because I dont get an idea how to access Joint in script.
Thanks in advance!

On the object that acts like it owns the joint (ahem, sorry), you can call GetComponent to access the FixedJoint. Then, you just need to use Destroy to get rid of it:-

var fj = GetComponent(FixedJoint);
Destroy(fj);

Thank you.
That what I have done and it works!
but again for reattaching the object , I used

fixjoint=ROVobj.AddComponent(FixedJoint);
fixjoint.breakForce=Mathf.Infinity  ;
fixjoint.breakTorque=Mathf.Infinity  ;
fixjoint.connectedBody=GameObject.Find("-TMS-").rigidbody;

but here I want the object to be connected at the center point of connected body as it was previously.
i.e when user try to connect else where, it should not allowed to him connect.

Thank you.
That what I have done and it works!
but again for reattaching the object , I used

fixjoint=ROVobj.AddComponent(FixedJoint);
fixjoint.breakForce=Mathf.Infinity  ;
fixjoint.breakTorque=Mathf.Infinity  ;
fixjoint.connectedBody=GameObject.Find("-TMS-").rigidbody;

but here I want the object to be connected at the center point of connected body as it was previously.
i.e when user try to connect else where, it should not allowed to him connect.

Solved :slight_smile: