- Home /
Moving a Rigidbody and then connecting a joint?
Hi all, i'm trying to make a little manipulator work.
I've got code which finds a rigidbody that i click on, and then runs this function
void Connect()
{
body.position = target.position;
//connector.connectedBody = target;
}
Note the second line is commented out. Connector is a fixedJoint attached to this object, body is a reference to this object's own rigidbody. The above code works fine, all it does is move this object to where the target is.
However, if i uncomment that second line, which assigns the target as the connected body of our joint, then the first line fails. The manipulator doesn't move, it just stays put. This is irksome.
I need the manipulator to move to the target, and THEN connect to it. This doesn't seem complicated, what am i missing?
Answer by Nanako · Jun 13, 2015 at 04:14 AM
I was unable to get this working.
I found out that as long as a fixedJoint exists, it connects to something. If it's not assigned a connectedBody, then it connects to 0,0,0 in the world, and thus can't be moved.
The best solution i found was to NOT create the fixedJoint at authortime. Instead, to dynamically create it (and immediately assign a connectedbody) at runtime when needed, and then to destroy it when not needed.