Snap two objects together based on the distance


In short, Im trying to snap 2 blueprints that contain a " room " made of static meshes, both with a door, Im doing a trace from the doors of each room so if the trace intersects with a door of another room, it should snap said room ( as well its rotation ) to the room door it just hit, here is an example

I had this working before but only when i tried to snap a room of a set size to any other room , I would get a reference to the room that was hit, Get its rotation and forward vector, and multiply that by a set amount so it would " push " the room out. Of course this wouldnt work once i added rooms of different sizes. So im trying to somehow move the room X units " forward " until both doors are overlapping so they end up snapped together

How exactly do you trace? To detect doors you’d need to know where a door is no?

If you have the location of the doors already you can calculate the distance from trace start to trace hit, rotate the room appropriately (you know what direction the door is. Adapt it so the other door aligns. If you have trouble with the exact math show what you got and I’ll take a look at how to fix it :wink:

And finally move your room that should snap by the length of the distance you calculated towards the door.

That should do it in theory.

Sorry if I made wrong assumptions. If I did could you show / elaborate on how you had it working and what exactly you’re tracing so far?

Yeah im using a trace to detect when there is a door, I do have the locations and distance between the door alredy, i couldnt figure out what exactly i should do with these though , I dont need to change the rotation of the room i really only want to move the room itself towards the door that was hit by the trace, so they end up connected as seen on this example

Heres what im using so far

Using that i can snap the room just like in the screenshot, But of course if i try to snap it from the door in the front of the room or use a room with a different size / layout it gets messed up, Thanks for the quick reply by the way!