Rigidbody and collider controlled by 2 gameObjects

Hi, I want to create a rigidbody and collider that is controlled by 2 gameObjects at the two ends like in the below image:
38415-collider.png

The two gameObjects can move freely in space, and the Collider must update accordingly.
How can I do it?

  • You know the center (go1’s pos + half the vector from go1 to go2), that’s the position.
  • You know distance between them, that’s the size.
  • You know the direction from one to another, that will help find the rotation.