How to stretch cylinder along longer side ?

Hi guys, I have an issue with the axis of a cylinder.

I’ve got two balls and a cylinder being stretched between them. When I click and move one of the balls I want the cylinder to scale between them. As I run Unity the cylinder is stretched along its Z axis (the shorter part of the cylinder).

I want it to be stretched along the Y axis (the longer part of the cylinder) but when I change scale.z = scale0.z to scale.y = scale0.y it elongates the cylinder obliquely because the transform.LookAt(pB) function runs on a different axis.

The code is:

Transform ballA; 
Transform ballB; 
Vector3 scale0; // initial localScale
 void  Start (){
   scale0 = transform.localScale;
 void  Update (){
   Vector3 pA= ballA.position;
   Vector3 pB= ballB.position;
   transform.position = (pA+pB)/2; 
   transform.LookAt(pB); // make it look to ballB position
   // adjust cube length so it will have its ends at the sphere centers
   Vector3 scale= scale0;
   scale.z = scale0.z * Vector3.Distance(pA, pB);
  // stretch it in the direction it's looking
   transform.localScale = scale;

How do I adjust LookAt and the scale axis so that the cylinder is stretched between the balls along its longer side ?

Thanks in advance!

In almost all cases, it’s easier just to child the object to an empty, and rotate so +z of the combined object is the way you want. Lots of explanation in UA, if you can guess correct search terms. Also a common modelling trick.

Otherwise, you can adjust the rotation later. LookAt always aims your +z, which means your +Y always needs a 90 degree x-spin to be looking. So can use (from memory): transform.Lookat(thing); transform.Rotate(90,0,0);.