Spawn Actor, positioning help needed. Align locations of components of two actors

Yeah, I’m really bad at explaining things. I was trying to simplify it by removing the context, but maybe it will help. The shapes are rooms of a randomly generated map. The components are doorways.

The entire thing will end up building many many rooms, but for now I am simply trying to get one single room to spawn correctly. I have placed RoomA on the map and its event graph will perform the following functions:

Note: “Doorways” are the vector components of the actor. There are 4 per room, already positioned and rotated correctly.

  • Randomly pick a doorway (let’s call it DoorA) from RoomA (The 600x600 square room)

  • Randomly pick a new room to spawn (Let’s simplify this to always picking “RoomB”, the 400x400 L-Shaped room)

  • Randomly pick a doorway from RoomB (DoorB)

  • Align DoorB with DoorA. This is obviously the part we’re focusing on.

    • Rotate RoomB to the correct rotation so that when DoorB is aligned with DoorA, the rooms are not overlapping. How can I accomplish this?

      • I just typed up exactly what I had been doing and realized it is absolutely wrong. I don’t know what I was thinking. It worked for the specific scenario I was testing but it wont for other cases.

      • Using the above graphs/drawings as a reference… if I place RoomB/C4 at RoomA/C4, it needs to be rotated 180 degrees.

      • If I place RoomB/C4 at RoomA/C3, it needs to be rotated 270 degrees. In the end, DoorB needs to be DoorA + 180 degrees. I can get DoorA's rotation, add 180 degrees, then subtract DoorB's rotation and apply it to RoomB... which is exactly what you said before. Ok.
    • Change DoorB’s location to be equal to DoorA’s location.

      • Here is where I may need to incorporate Fen’s solution. I may need to check DoorA’s rotation and perform the movement calculations based on that.

      • The only way I can see this working dynamically is by determining the amount of units both FORWARD and RIGHT that RoomB should be away from DoorA. I dug up some old geometry lessons to see if I could find anything helpful, but unfortunately I don’t think there’s anything I can do if I only know it’s a 90 degree triangle and the length of the hypotenuse.

      • 9ll3h8r.png

      • I could cheat. I could, in addition to having a vector for each door, have another vector at each side of the room right in the middle.

      • PAoYeTe.png
        In doing this, if I was looking to calculate DoorA, I could use the distance from SideA to the center to get the forward vector and the distance from SideA to DoorA to get the right vector.
        I don’t like flooding my components with extra stuff just to cheat, but I don’t know what else there is.

I cheated - hardcore. Gave each room an array containing the appropriate offsets for each door. So I know if I pick “door 1”, I need to go forward 195 units and right -100 units. I’m not proud of cheating but I honestly couldn’t find another way and I’m ready to move on to another part of this project. Thanks for the replies and if anyone has any better ideas, feel free to post.