Hi!
I am working at some kind of lego in UE. Now I have problems with making them connecting properly: in my Lego, they could be connected not only to the upper side of block, but also to left or right of block.
I made 6 colliders for all sides of blocks and checking - is there another block nearby. How can I attach it properly to the other block? I mean, that they must be on one height and be rotated properly.
Is there any preset ore simple approach in UE4 for easy realization of this?
With best regards
P. S. Maybe it would be simpler to realize in C++?
Made some realization.
I have the parent blueprint for interacting with leap motion, and his child blueprint, which supports the connecting features.
In child, I added arrow components, which are used as sockets - I attach the other block to it, and transform to the arrow position.
The problem is that my realization for some reason works only when I am connecting blocks upside down… If I am moving one block to other from left to right, then I can’t see the wanted result…
Maybe there is more simple architecture of what I am trying to do?
not sure if I understand it right but I would set the placeable blocks rotation = rotation of the other block, then depending on which side it should be I would take the forward (or right or up) vector and add / substract the size of the block from it. this way all blocks are aligned and you can place them on top, below, left or right.
The problem is that I need to use different materials for each cube, so I can’t use this approach.
I need to blueptints which connect together like magnets.
Can you give me your email, i’l send you exported blueprint?
It is made in 5-7 different functions/macros, so it would be hard to understand using pictures
How is my approach interacting with materials? ^^ I made 2 years ago a system where I could snap blocks to each other like magnets. worked fine with the way I told you.- YouTube this is a very old version, later they aligned perfectly but don’t have a picture of it. I could let them snap to the top to the bottom, left right front and back.
I don’t need to place block, i need to stick the existing blocks to each other
Attach to cant be used, because there is no parent and relative, both must move with other moving
After the sticking, i must have the ability to stick other blocks to them
Im not using “attached to”. You have one block that already is placed, then you want another to be snap to it so you give him the same rotation as the first block. Get the forward vector of the first block and substract or add the value of his size. If its 500 cm long and you want it to stick on the right you get the Right vector multiplied by 500 + vector of first block and it will be next to the other block if they have same rotation. you want it to be on top then get the upvector multiplied by 500 + vector of first block. and so on
ah I see you want them move as a whole ? in that case I would use one blueprint and all cubes are instances. this way you can have multiple materials and they move all together when the actor is moved
make “add instanced static mesh” and add it to an array.
option 1: you have to do math. delete and create new collision boxes based on where a snap happened.
option 2: you use only one collision box on the single cubes. give each mesh sockets for all of there sides. then, if your built cubes enter the collision box of the single part, you will set the single cubes position to the socket that is nearest to it. (+ half cube size) now you store the location and delete that cube, and add an instanced static mesh to that bp at the same rotation/location.
this is what I understand you want small parts to stick on the side of the big part where the collision hits but aligned with same rotation ?
use sockets instead of collision boxes for each parts (?)
Upgraded the old blueprint.
Now the problem is that if I am connecting a block which is already has parent block, then this will destroy the old relations and the figure will be detached…
I have a question here If you are still working or is still have some knowledge of this… are you able to combine or deform Collision mesh as you add to each block… im currently wanting to make sure of like a build-able Collision hit detection for things like swimming… or making hallway full of trap… etc. that has to work in runtime. It seams so silly that we cant have like a polygon shapped collision or least be able to merge collision box to make a polygon-ish collision hitboxes.
Reason why im asking is because if i place these too close to each other the overlap event on both would cause a begin and end overlap that causes huge issues. with the game not being able to understand what movement state it suppose to be in.