Detecting collision with object what touched and making a hinge joint between.

Hello, I really need a piece of script what can help me with it. I am making builder menu for my game and I want to get script like that:

function ??? ()
{
     if(Input.GetButtonUp("Jump"))
     {
           hingeJoint.connectedBody = //this one what touched.rigidbody;
     }
}

so, what i really need is something what detect collision with Exacly this one what touched and no it can’t really be OnCollisionEnter because i have to have some object named the same. Hope you will understand my question :slight_smile:

Here’s some info on the function OnCollisionEnter, it gives you the object you collided with when you collide with it and executes your code when the collision occurs.