Is there a Distance Constraint 3D or Distance Joint 3D in Unity?

Is it possible to do a distance constraint/joint constraint in Unity?
For example, consider 2 cubes, 2 unit apart, as the following;

[ ]--2 units--[ ] (controllable)

If we move the box on the right up or down (by using keyboard control), it will retain same distance, 2 units exactly, as the following;

    [ ] (controllable)
    /
   2 units
  /
[ ] 

It seems that we have Distance Constraint 2D, but is there a Distance Constraint 3D in Unity?

I believe the best way to do this would be using a ConfigurableJoint and setting it’s linear limit to the distance you want.

well i would get the distance of 1 and compare it to the other … from there you can set a constraint of distance to your likeing.

var target : Transform; 
private var myTransform : Transform;

function Awake(){
myTransform = transform; //here i cached the transform for performance
}  

function Distance(){
var direction : Vector3 = target.position - myTransform.position;//declare direction

  if (direction.x > 2){
    //Your code here if the distance on the x is GREATER than 2
 }
  else if (direction.x < 2){
  //Your code here if the distance on the x is LESS than 2
 }
}