# How can I snap one side of a cube to another in-game?

I basically want cube # 2 to snap to one side of cube # 1 when it overlaps.

Is there a node I can use to get the eight corner of the cube or something?

You can do a line trace. It basically “draws” a line between two points (your mouse location and each side for like 500 units or something) and returns you a hit result if it hit something. You can break that to get the location and type of the hit actor so if it is another cube you can simply set the location to right next to it.

Keep in mind that you can’t just use your actor location because that wouldn’t change once it’s connected anymore… ever.

I hope this helps.

Cheers

Hi!
Having the same problem. If you solved this, could you answer?

Hi, yes I did in fact solve it ages ago. I didn’t see your comment until now. I see you haven’t posted in your forum thread so lemme know here if you’re still trying to solve it.

Hi
Yes, I still have problems with it

Hey Van,

What you want is the “bounds” for both objects, the node would be, Get Component Bounds, or Get Actor Bounds, depending on what you are dealing with, or want to deal with. They will return origin and extents, the extents are 1/2 the “size” of the box. From that you can calculate your *8 corners".

Hope this helps,

.

Jayice gave a good answer for cubes specifically…

However I needed this answered for a survival-type building system.

Here’s what I did that worked very well: Each “building” piece had overlap components, along with arrows, and if say, the right side of wall #1, overlapped with left side of wall #2, the two arrows inside of those overlapped components would snap together and form a larger wall.

That’s it. Hope it helps… If you’re only trying to do cubes… My method would work too, but, as I said, jayice gave a good answer (And Erasio)

And here’s a video of it in action from ages ago: 2015 03 25 2021 43 - YouTube

Hi, anyone have the final blueprint of this solved problem using “Get Component Bounds”, or “Get Actor Bounds” ?