Hi, I’m working on a game and need to place the part on top of another part even if it’s with angle.
Need to place part 2 (top one) on the blue X I draw there.
I set part2’s Y position to be half of part2 Y size + half of part1 Y size + part1 Y position, but I got the same thing as in the picture. I need to move it down and right like the red arrow is pointing to so they would be aligned.
This is how it looks like when I rotate them together.
I can’t calculate the length from part2’s pivot to the X mark. I’ve tried to move it by half of part2’s X size and a few more like sizeX/3, sizeX/4, sizeX/6 and sizeX/9 (sizeX/math.huge = 0 so it’s useless).
part2.Position = Vector3.new(
part1.Position.X + ???,
part1.Position.Y + part1.Size.Y/2 + part2.Size.Y/2, -- This works perfectly if parts are exactly 90 degrees on the baseplate.
part1.Position.Z, -- I'm not sure if I'll need to fix even Z, but size X is the same as size Z.
)
-- Note: Both parts must be the same rotated
Thank you for your response.