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.