Combining Objects Together (Urgent)

Hi there!

I just got into UE4 with the aim of generating synthetic images to train my neural network.
The goal of the neural network is to predict the stability of a block tower consisting of cuboids under various configurations that are stuck together.

A simple example of what I’m referring to can be found in the image of Tetris pointed to by this link: https://upload.wikimedia.org/wikipedia/commons/3/39/Tetrominoes_IJLO_STZ_Worlds.svg
, where the red tetrimino can be seen as an “upper stick” stuck on top of a “base stick”. If the upper stick is heavier than the base stick to a certain extent, the who tetrimino will tilt to the right and topple, otherwise it will not.

In reality it is a pushover to make a tower of this nature simply with glue, but obviously it is not an option in Unreal and I’m having difficulty simulating it. So, I’m asking if there is a way in Unreal to stick several cuboids together as if they were glued together, so that all the objects form a block tower and their respective physical properties remain unchanged? This way, when I hit PLAY, I can see whether the block tower will topple.

P.S. It would be really helpful if the suggested approach could be implemented in a script, because I need a huge number of randomly formed block towers to be generated automatically, and I’m planning on controlling it with Python.

N.B. This is my undergraduate final year project, and time is running out, so swift answers will be really really really appreciated!!!

If I understand you correctly, then yes. It is possible.
You will want to research the following commands.

pMeshComponent->RegisterComponent();
pMeshComponent->AttachToComponent(pRoot, FAttachmentTransformRules::SnapToTargetIncludingScale);

Perhaps there is a better way, but if so, then I don’t know it.

Thanks for your answer! I have tried both AttachToComponent and AttachToActor in Blueprint, but they apparently work in the same undesirable way. I have demonstrated how AttachToActor didn’t work with a video here: link text. Obviously, when I hit PLAY, the upper cuboid was attached to the lower cuboid as its child object, but the upper cuboid then just became invisible. The influence of the invisible upper cuboid was evident, as the whole rigid body (of which only the lower cuboid was visible) kept tilting and the motion was perpetuated, which is against the laws of physics. In reality, the whole thing would just become stable after a few “rounds” of tilting. What do you think could be the reason behind it?