Reducing the distance between 2 objects in a hinge

I currently have this code:

#pragma strict
var lockPos = 0;

function Start () {
}

function Update()
{

transform.rotation = Quaternion.Euler(lockPos, transform.rotation.eulerAngles.y, lockPos);
}
function OnCollisionEnter(collision: Collision) {

if (collision.rigidbody) {

   var fixedJoint: FixedJoint = gameObject.AddComponent(FixedJoint);

   fixedJoint.connectedBody = collision.rigidbody;

   fixedJoint.breakForce = 1000;
fixedJoint.
   fixedJoint.breakTorque = 1000;
   }
   }

It works fine, no problems. But the distance between the 2 objects is a noticeable difference. I’m curious how/if i can with a fixedHinge can i reduce that distance.

Basically my object is coming from a launcher and i want it to stick to the object in place, the light grey are the ones that are being launched, the dark grey is the one that i want to be the base.

My question is:
A. Can the distance shown between be made to be connecting?
B. Is there an easier/more efficient way to do this that allows the same physics?

[2537-too+far.png|2537]

The above image is from my unity screen, the 2 lighter grey objects ARE connected to the dark grey object with the joint.

Thank you, used this forum a lot for other problems I’ve had and hope that you guys could give me a hand here!

I think you can add the following to OnCollisionEnter:

    var temp0 : Vector3;
    var temp1 : Vector3;
    var temp2 : Vector3;
    
    temp0 = collision.transform.position;
    temp1 = transform.position;

//Step1  
    temp2 = temp1 - temp0;
//Step2
    temp2.Normalize();

//Step3
    temp2 *= radius + radius; //or radius1 + radius2 //addition is faster than multiplication
    //not that it matters much for something so simple;
//Step4
    temp2 += temp0;
    
    transform.position = temp2;

Basically,

  1. take the position of the white ball and find the direction compared to the gray ball.

  2. make the distance of this direction 1 meter long (if it’s 10 meters away the distance will be one meter compared to the origin (0,0,0), perhaps something like (.707,0,.707) or (1,0,0).

  3. multiply by the combined radii (if one ball were bigger with a radius or 2.5 and the others had a radius of .5 for instance, you would multiply by 3…

  4. add this relative position to the actual position of the gray orb

For step 4: the position of an object with respect to world space is the position relative to another object plus the distance of that other object with respect to world space.