I have a wire(very thin cylinder) between 2 boxes. How can I connect the ends of the wire to the 2 boxes so when I move the boxes(vertically or horizontally), the wire would move too?
It depends on what the behavior you’re looking for on the wire, do you want it to stretch and always appear taut ? Would you prefer that it get slack when the two boxes are brought together and transfers force to the other when they are moved apart?
In the first case I’d just write some functions to keep the cylinder rotated and scaled to match the positions of the boxes it’s attached to.
In the latter case I’d make the wire out of a succession of small cylinders attached by joints. The type of joint depends on the directional freedom of the boxes. If they’re only moving in 2 dimensions you’ll want to use a hinge joint, otherwise you’re going to use a configurable joint.
http://unity3d.com/support/documentation/Components/class-ConfigurableJoint.html
I hope that should be enough to get you started…