r/Unity3D•
milotoad

Breaking joints

So I have this:

void OnCollisionEnter(Collision c) 
{ 
	var joint = gameObject.AddComponent<FixedJoint>();
	joint.connectedBody = c.rigidbody;
}

and its tied to the object I am picking up but I want to be able to delete this joint when I press a key so I can drop the object I picked up with

Destroy (joint);

would I put that in the same class in the Update() method?

Posted Dec 14, 2014, 4:28 PM UTC

21
BlackDragonBE•

You'd put an input check in Update() for the key you want to press and then either destroy the joint or disconnect it if you need it later.

1