Attach Component to another component

Hi all,
this is my first time to use UE4
and i have problem to attach component to another component
for the example i have bottle and bottle cap and i want to attach both in vr ( vr template )
anyone knows how to do it?

Look inside BP_PickupCube under Blueprints in the standard VR template. It shows how you attach an actor to the motion controller once you pick it up. The same applies if you want to attach yet another actor to it.

Mind the fact that if you are holding an actor in one hand and you want to attach the cap with the other hand, you need to detect the overlap of the cap attached to the second hand with the bottle attached to the first hand and then swap the cap by detaching it from the second hand and attaching it to the bottle (and hence to the hierarchy of the first hand).

If you are new to UE4 this can be tricky at first. Give it a try and report here for more help if needed.

Hi @vr_marco,
I have tried the blueprint in BP_PickupCube and there are no results :frowning:

can you teach me how to detect the overlap in this case the bottle and cap ?

Overlaps between actors are a basic functionality of UE4. If you are not sure about how they work, I would recommend you read first the online documentation or follow some of the many YouTube courses/tutorials.
In few words, you create overlap detection events (E.g. On Begin Overlap event) for your actors and you react to them by making something “happen”. In your case attaching the cap to the bottle for example.

Hi @vr_marco ,
thanks for your advice before, now i can attach the cap to the bottle.
it just add blueprint in the level and overlap the cap attach to socket in the bottle.

thanks a lot :slight_smile:

now the problem is when the bottle and cap are not too close. the cap is immediately attached to the bottle.
is there something wrong ?

Good! Glad it worked. Check the size of your overlap area. Something is triggering it. You have to cast to the cap blueprint to make sure it is the one causing the overlap, otherwise something else may cause it to trigger and the cap still gets attached.

Hi @vr_marco ,

I have a problem again, I thought before I managed to attach the two actors but I don’t think so. because I tried to take 1 actor and I get close the two controllers together, the two actors were able to atach without getting closer. can u explain something about it ?

I don’t think it is a collision / overlap issue. There may be something triggering the attach which you have not excluded. That’s why I was recommending you to always cast to make sure the overlap is generated by the right actors.

Seems you have the basic working , but you have made the cap attach to the bottle as soon as it detects the overlap.
You should introduce another condition like, only if a the grip button is not held , and then run that through a branch to the attach to component.
then it will only attatch when you let go