Aligning a edge of a part to a rotated part

Hello,

I have been trying to find a math algorythm to align a corner of a part to a rotated part by changing one axis but i cant find it and there are generally not alot of math equations for building tools from what i can find.

As seen in this picture the example is kinda what i want to achive but in the example i can’t really set the Z axis to whatever i want without it not aligning to the blue part.

I would really appreciate some help here.

1 Like

Not sure what you mean, but if I understand, I believe f3x has that feature.

No, if I would want the Z axis to be exactly 6 for example I can’t really set it to that without it not aligning to the blue part

1 Like

For this you just have to do some simple CFrame math. Lets say the blue part is called Part1 and the red part is called Part2. You would just get the CFrame of the blue part, and add an offset of half the size of the blue part plus half the size of the red part (so the edges align). You would do so like this:

Part2.CFrame = Part1.CFrame * CFrame.new(0, 0, (Part1.Size.Z / 2) + (Part2.Size.Z / 2))
1 Like