Need help with rotations

So I want to create a pipe type of thing using Cylinder. So I’ll create a cylinder but I want this cylinder to be between two points that I do not know. Here’s how I did it:

edge.transform.position = new Vector3 ((src.transform.position.x+dst.transform.position.x)/2, (src.transform.position.y+dst.transform.position.y)/2, 0);
edge.transform.localScale = new Vector3 (7, Vector3.Distance (src.transform.position, dst.transform.position)/2, 7);
float ang = Vector3.Angle (src.transform.position, dst.transform.position);
edge.transform.Rotate (0, 0, 360-ang, Space.World);

So basically src is my source, dst is my destination. The scaling seems to the right size but the rotation is always wacky. Maybe I don’t know how it works but the rotation is always below 90and I just can’t figure out how to do this.

I would use a modelling program to make a cylinder of length 1 starting at the origin and aligned with the Z axis. Then you can just place it a position A, use transform.LookAt(position B) and change its local Z scale to (B-A).magnitude

Not sure what you mean. I don’t want to change the Z at all because I’m working on the xy-plane so it’s technically 2d.

I mean the model’s Z axis. That way transform.LookAt(target) will align the cylinder with the line between its position and the target.

Thanks a lot for your help! Got it!