Download

Spawn and attach item object to a socket

I’m looking for many hours now for adding an item (static mesh or skeletal mesh) to a socket on my blueprint.
I have an inventory system, and when i take an object (a weapon) from my inventory, i want to add in on my socket (in the hand of my character).

5a24d6f2479e25dca1c2965f1a225818021b87f5.png

ue4 bp2.png

Anyone know how to add a weapon to my socket ?
The name of my socket is : “objet_saisi”.

Thanks for the help.

Complicated thinking… I’d just destroy the player actor (holding a book mesh) and replace it with a “holding the gun mesh” actor if you for example switch from a book to a gun. If you don’t even use hand/arm meshes this should be fairly easy.

It can be maybe a solution, but normally i can add a mash (static mesh or skeletal mesh too) on my character with a socket.
I’m still thinking about this.

nobody know how to resolve this ?

Where the problem come from ?

Capture.PNG
this is as close as i’ve gotten to the solution. right now i have a blueprint base for weapons, then two child blueprints. i set the reference variable defaults to those two and i can swap back and forth between them. i’m just stuck on getting it to stick to a socket because right now the object snaps to the center of the body and moves with the socket slightly. i use blueprint class variable because it allows me to easily grab variables from each weapon (ie base damage, ammo type, reload animation), though actor reference might also work. the weapon select index can be ignored. i’m also experimenting with a weapon wheel

Capture.PNG
Capture.PNG.jpg
messed around with it a bit more. this should do the trick. i’ve also included a screenshot of the weaponbase blueprint. you can add whatever variables you want to it but all you really need is the scene component and an empty child mesh component. once you make a child blueprint of it, you can swap out meshes inside the child blueprint pretty efficiently. last suggestion for good procedural item builds is to make a name variable in the baseweapon blueprint. then, in the each child blueprint, go to class defaults and give the socket name variable a new name that corresponds to the sockets on the character where you want a specific item to attach to on the character (ie name variable “hand_r” for items used in right hand), then link it up from spawn actor ‘return value’ to the attach ‘socket name’ node. that way you could reuse for armor, clothes, etc without having to redo this system. although, it probably would be tricky to use both the socket linking and swapping unless you make a separate left and right version of every weapon. anyway, good luck

edit: i messed up the last, temp, current order for weapon swapping. here’s what im using now
7be873a1c8b4edc3ab32495c9c54ed35338bc936.png

Hi, thanks for you reply !

But i have a question, i’ve see fast your work.
But i thinking, and someone told me, i need to use a controller (a child of Player Controller class or the Player Controller himself in C++) because i have an inventory where i have my blueprint, and he told me i need to call the other class.
One class for my objet who is a child of an item master (mother class of object who can be in my inventory) in my inventory system, and the class for my object mesh (the reference).
Do you think your technique can work with my problem ? Or do i need to use him solution ?

Thanks for your reply

Hye would love to try this if you dont mind but what is the node that the first set node is tied to? Hoping this work what I am looking for is no matter what weapon blueprint I put in my action bar 1-9 it will spawn it in the hand? Thanks for any and all help

Hey would love to try this if you dont mind but what is the node that the first set node is tied to? Hoping this work what I am looking for is no matter what weapon blueprint I put in my action bar 1-9 it will spawn it in the hand? Thanks for any and all help