How to find the Orientation between 2 parts?

Ok, so I got 3 Parts:

  • Red
  • Blue
  • White (Created with a Script)

I already found the mid-Vector3 by doing:

White.Position = (Red.Position + Blue.Position) / 2

See Here:

Now I’m trying to correctly orient the White part so it is in line with the Red and Blue parts.
Like this:

Do you know an equation that can do this?

You can just do:

Line.CFrame = CFrame.new(Blue.Position, Red.Position) + MidPoint.Position

Basically, you get the lookvector of the 2 points and add it to the position with CFrame.new((Pos1, PosLookAt)

But how does this get the Orientation?

It’s documented on the developer hub:

2 Likes

Thanks, bro! I hope others come across this.

1 Like

You can also do

local LookAt = (Part1.Position - Part2.Position).Unit

to get the LookVector between 2 parts

1 Like