Attach a game object to the side of another?

I’ve searched and searched, but I can’t find this particular situation addressed anywhere. I am trying to make a level design tool for a physics based game. The purpose of the tool is to form a platform, one section at a time. I’m using a simple cube with a scale of (1f, 0.25f, 1f), so essentially a rectangle. I want to be able to specify straight, 45 degrees or 90 degrees, along with left or right and up or down to tell the engine to place the next segment on the left or right of the current segment; going upward, downward or straight out. I want to get the sides to ‘attach’ by affixing the outer corners.

For example, if the current block is lying flat (no rotation) and the next block is to be placed on the right at 45 degrees down, the upper left corner of the new block should be at the same position as the upper right corner of the current block. Assuming the next block should again be laid flat, then the lower left corner of the new block should align with the lower right corner of the 45 degrees block (see the picture below). I’m SURE there is some cool function that will tell me where the corners are, even when rotated (the Mesh.vertices returns all of the points, but not rotated in world space), but I can’t find it or an algorithm that will help.

A screen capture of what I am trying to accomplish is below. Can anyone provide some guidance or a better way to procedurally create platforms in a level? This is a physics game, not a platformer, just to reiterate.

Thanks in advance!


Alas, after all of that searching, I finally found the CORRECT terms to search for and the answer is Transform.TransformPoint. Along with identifying the corners of the GameObjects (parent and child) using Mesh.vertices and finally finding the front most corners to use as input into Transform.TransformPoint. The last piece of the puzzle was using simple vector math to adjust the location of each new piece. With all of that in place, the angle used is irrelevant and just knowing ‘left/right’ and ‘up/down’ tells the code which two corners to match up.