title: Unity3D : make cylinder stretch from one point to another
body: <p>I'd like, at each frame, to move, scale and rotate a given cylinder so that it behaves like a 'rope' between two points.</p>
  
  <p>I have this code at the moment, but it doesn't work at all like intended :</p>
  
  <pre><code>hook.transform.position = (rightHandPosition + hookDestination)/2;
  
  hook.transform.localScale = new Vector3(0.5F, Vector3.Magnitude(hookDestination - rightHandPosition), 0.5F);
  
  hook.transform.rotation = Quaternion.Euler(hookDestination - rightHandPosition);
  </code></pre>
  
  <p>As you can guess the two points are rightHandPosition and hookDestination. For now, the cylinder spawns at 'random' locations, with 'random' rotations and enormous scales.</p>
  
  <p>How can I fix it ?</p>
  
  <p>"Full" script :</p>
  
  <pre><code>public class FirstPersonController : MonoBehaviour {
  
      public GameObject hook;
      bool isHooked = false;
      Vector3 hookDestination;
      Vector3 rightHandPosition;
  
      void Start() {
          hook.renderer.enabled = false;
          rightHandPosition = hook.transform.position;
      }
  
      // Update is called once per frame
      void Update () {
          if (isHooked) {
              hook.transform.position = (rightHandPosition + hookDestination)/2;
              hook.transform.localScale = new Vector3(0.5F, Vector3.Magnitude(hookDestination - rightHandPosition), 0.5F);
              hook.transform.rotation = Quaternion.Euler(hookDestination - rightHandPosition);
          }
  
          if (isHooked &amp;&amp; !Input.GetMouseButton(1)) {
              isHooked = false;
              hook.renderer.enabled = false;
          }
  
          if (Input.GetMouseButtonDown (1) &amp;&amp; !isHooked) {
              Ray ray = GameObject.FindGameObjectWithTag ("MainCamera").camera.ViewportPointToRay (new Vector3 (0.5F, 0.5F, 0));
              RaycastHit hit;
              if (Physics.Raycast (ray, out hit) &amp;&amp; hit.distance &lt; 5000000 &amp;&amp; hit.collider.tag != "Player") {
                  isHooked = true;
                  hookDestination = hit.point;
                  hook.renderer.enabled = true;
              }
          }
      }
  }
  </code></pre>
  
  <p>A screenshot of the scene :</p>
  
  <p><a href="https://i.stack.imgur.com/sSGnV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sSGnV.jpg" alt="hook behavior (bug)"></a></p>