I’m trying to create a function that creates a part that resembles a line and ‘connects’ two parts with it, but I’m completely lost.
Here’s a visual representation of what I mean:
I have code to make the line the appropriate length:
path.Size = Vector3.new((pos1 - pos2).Magnitude, 0.1, 0.1)
I’ve also got it to spawn the line part directly in between the two parts, so all that’s left is getting the correct orientation.
I’ve used different combinations of atan, asin and acos to try and figure out what the line’s orientation should be, but when I figure out what works for two objects with a certain position, it fails for any other objects with a different position. I’ve tried creating visualizations in MS paint but end up even more confused. My brain is pretty much fried from trying to figure this one out all day. How can I best calculate what the line part’s orientation should be?