- Home /
Question by
rymski86 · Jul 02, 2011 at 06:57 PM ·
hingejoint
how connect 2 object
hi all, how to connect and disconnect the two objects using key.space and hingeJoint
or otherwise
Please help, I have no ideas :(
from other question
how attach 2 object eg. tractor and trailer.
"hingeJoint.connectedBody" not work bcs trailer attach each side
var otherBody : Rigidbody;
function OnCollisionEnter (collision : Collision) {
if (collision.rigidbody){
hingeJoint.connectedBody = otherBody;
print("ho");
}
}
function Update () {
if (Input.GetKey(KeyCode.Z)){
hingeJoint.connectedBody = null;
print("hi");
}
}
Comment
ok how negate this ""hingeJoint.connectedBody = otherBody;""
Answer by DaveA · Jul 03, 2011 at 02:13 AM
Ideas are here: http://unity3d.com/support/documentation/ScriptReference/Joint-connectedBody.html?from=HingeJoint
and
http://unity3d.com/support/documentation/ScriptReference/Input.GetKeyDown.html