How do I connect two objects on contact

I’m new to unity and I have been experimenting with a very simple 3D scenario where two blocks are falling onto a plane, one above the other and want to connect one to the other when they come into contact, preferably if the blocks are skewed I would want the connection to be in the center of the side that is contacted, so that the connection is seamless. How would I go about this?

You can make a script and put it on one of the cubes. You could use OnCollisionEnter(Collision col)
and then make an if statement checking if the collision (col in this case) is equal to the cube you want to attach. Then set the parent of the other cube equal to the script. I have written it here:

public GameObject otherCube;

void OnCollisionEnter(Collision col) 
{
    if (col.transform.gameObject == otherCube) 
{
    otherCube.Parent = gameObject;
}

}

Hope this helped!